2019-11-10 03:11:43 +09:00
|
|
|
from yandex_music import GeneratedPlaylist
|
|
|
|
|
|
|
|
|
|
|
|
class TestGeneratedPlaylist:
|
|
|
|
type = 'playlistOfTheDay'
|
|
|
|
ready = True
|
|
|
|
notify = False
|
|
|
|
|
|
|
|
def test_expected_values(self, generated_playlist, playlist):
|
|
|
|
assert generated_playlist.type == self.type
|
|
|
|
assert generated_playlist.ready == self.ready
|
|
|
|
assert generated_playlist.notify == self.notify
|
|
|
|
assert generated_playlist.data == playlist
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert GeneratedPlaylist.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert GeneratedPlaylist.de_list({}, client) == []
|
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
def test_de_json_required(self, client, playlist):
|
2019-12-27 05:27:58 +09:00
|
|
|
json_dict = {'type_': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
|
2019-11-10 03:11:43 +09:00
|
|
|
generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert generated_playlist.type == self.type
|
|
|
|
assert generated_playlist.ready == self.ready
|
|
|
|
assert generated_playlist.notify == self.notify
|
|
|
|
assert generated_playlist.data == playlist
|
|
|
|
|
|
|
|
def test_de_json_all(self, client, playlist):
|
2019-12-27 05:27:58 +09:00
|
|
|
json_dict = {'type_': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
|
2019-11-10 03:11:43 +09:00
|
|
|
generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert generated_playlist.type == self.type
|
|
|
|
assert generated_playlist.ready == self.ready
|
|
|
|
assert generated_playlist.notify == self.notify
|
|
|
|
assert generated_playlist.data == playlist
|
|
|
|
|
|
|
|
def test_equality(self, playlist):
|
|
|
|
a = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
|
|
|
|
b = GeneratedPlaylist(self.type, False, self.notify, None)
|
|
|
|
c = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
|
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert a == c
|