Добавлены основные тесты для следующих классов: AlbumEvent, AlbumsLikes, ArtistEvent, ArtistsLikes, ChartItem, Dashboard, Day, Event, Sequence, StationTracksResult, Supplement, TrackWithAds.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен conftest.py.
Исправлен баг в .to_dict() методе, связанный с не рекурсивной десериализацией объектов списков и словарей.
Исправлен баг с десериализацией artist в классе ArtistEvent
2019-11-09 22:43:02 +09:00
|
|
|
from yandex_music import Day
|
|
|
|
|
|
|
|
|
|
|
|
class TestDay:
|
|
|
|
day = '2019-11-09'
|
|
|
|
|
|
|
|
def test_expected_values(self, day, event, track_with_ads, track):
|
|
|
|
assert day.day == self.day
|
|
|
|
assert day.events == [event]
|
|
|
|
assert day.tracks_to_play_with_ads == [track_with_ads]
|
|
|
|
assert day.tracks_to_play == [track]
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Day.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Day.de_list({}, client) == []
|
|
|
|
|
Добавлены основные тесты для следующих классов: AlbumEvent, AlbumsLikes, ArtistEvent, ArtistsLikes, ChartItem, Dashboard, Day, Event, Sequence, StationTracksResult, Supplement, TrackWithAds.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен conftest.py.
Исправлен баг в .to_dict() методе, связанный с не рекурсивной десериализацией объектов списков и словарей.
Исправлен баг с десериализацией artist в классе ArtistEvent
2019-11-09 22:43:02 +09:00
|
|
|
def test_de_json_required(self, client, event, track_with_ads, track):
|
|
|
|
json_dict = {'day': self.day, 'events': [event.to_dict()], 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
|
|
|
|
'tracks_to_play': [track.to_dict()]}
|
|
|
|
day = Day.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert day.day == self.day
|
|
|
|
assert day.events == [event]
|
|
|
|
assert day.tracks_to_play_with_ads == [track_with_ads]
|
|
|
|
assert day.tracks_to_play == [track]
|
|
|
|
|
|
|
|
def test_de_json_all(self, client, event, track_with_ads, track):
|
|
|
|
json_dict = {'day': self.day, 'events': [event.to_dict()], 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
|
|
|
|
'tracks_to_play': [track.to_dict()]}
|
|
|
|
day = Day.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert day.day == self.day
|
|
|
|
assert day.events == [event]
|
|
|
|
assert day.tracks_to_play_with_ads == [track_with_ads]
|
|
|
|
assert day.tracks_to_play == [track]
|
|
|
|
|
|
|
|
def test_equality(self, event, track_with_ads, track):
|
|
|
|
a = Day(self.day, [event], [track_with_ads], [track])
|
|
|
|
b = Day('', [event], [track_with_ads], [track])
|
|
|
|
c = Day(self.day, [event], [track_with_ads], [track])
|
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert a == c
|