2019-11-08 02:09:39 +09:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from yandex_music import PlaylistsLikes
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='class')
|
|
|
|
def playlists_likes(playlist):
|
|
|
|
return PlaylistsLikes(TestPlaylistsLikes.timestamp, TestPlaylistsLikes.id, playlist)
|
|
|
|
|
|
|
|
|
|
|
|
class TestPlaylistsLikes:
|
2019-11-10 03:11:43 +09:00
|
|
|
id = None
|
|
|
|
timestamp = '2019-06-21T05:41:46+00:00'
|
2019-11-08 02:09:39 +09:00
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
def test_expected_values(self, playlists_likes, playlist):
|
2019-11-08 02:09:39 +09:00
|
|
|
assert playlists_likes.timestamp == self.timestamp
|
2019-11-10 03:11:43 +09:00
|
|
|
assert playlists_likes.id == self.id
|
2019-11-08 02:09:39 +09:00
|
|
|
assert playlists_likes.playlist == playlist
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert PlaylistsLikes.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert PlaylistsLikes.de_list({}, client) == []
|
|
|
|
|
2019-11-08 02:09:39 +09:00
|
|
|
def test_de_json_required(self, client):
|
|
|
|
json_dict = {'timestamp': self.timestamp}
|
|
|
|
playlists_likes = PlaylistsLikes.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert playlists_likes.timestamp == self.timestamp
|
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
def test_de_json_all(self, client, playlist):
|
2019-12-27 05:27:58 +09:00
|
|
|
json_dict = {'timestamp': self.timestamp, 'id_': self.id, 'playlist': playlist.to_dict()}
|
2019-11-08 02:09:39 +09:00
|
|
|
playlists_likes = PlaylistsLikes.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert playlists_likes.timestamp == self.timestamp
|
2019-11-10 03:11:43 +09:00
|
|
|
assert playlists_likes.id == self.id
|
2019-11-08 02:09:39 +09:00
|
|
|
assert playlists_likes.playlist == playlist
|
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
def test_equality(self, playlist):
|
|
|
|
a = PlaylistsLikes(self.timestamp, self.id, playlist)
|
|
|
|
b = PlaylistsLikes(self.timestamp, self.id, None)
|
|
|
|
c = PlaylistsLikes(self.timestamp, self.id, playlist)
|
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert a == c
|