2019-11-08 02:09:39 +09:00
|
|
|
from yandex_music import Chart
|
|
|
|
|
|
|
|
|
|
|
|
class TestChart:
|
Добавлены основные тесты для следующих классов: Album, Artist, Chart, Counts, Genre, Label, PermissionAlerts, PromoCodeStatus, Restrictions, Settings, Station, StatuonResult, Status, Track.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен restrictions.py.
Исправлен баг в .to_dict() методе, связанный с десериализцией объектов списков и словарей.
2019-11-09 00:24:54 +09:00
|
|
|
position = 2
|
|
|
|
progress = 'same'
|
|
|
|
listeners = 1433
|
|
|
|
shift = 0
|
2020-05-16 04:41:30 +09:00
|
|
|
bg_color = '#666A61'
|
2019-11-08 02:09:39 +09:00
|
|
|
|
|
|
|
def test_expected_values(self, chart, track_id):
|
|
|
|
assert chart.position == self.position
|
|
|
|
assert chart.progress == self.progress
|
|
|
|
assert chart.listeners == self.listeners
|
|
|
|
assert chart.shift == self.shift
|
|
|
|
assert chart.track_id == track_id
|
2020-05-16 04:41:30 +09:00
|
|
|
assert chart.bg_color == self.bg_color
|
2019-11-08 02:09:39 +09:00
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Chart.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Chart.de_list({}, client) == []
|
|
|
|
|
2019-11-08 02:09:39 +09:00
|
|
|
def test_de_json_required(self, client):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'position': self.position,
|
|
|
|
'progress': self.progress,
|
|
|
|
'listeners': self.listeners,
|
|
|
|
'shift': self.shift,
|
|
|
|
}
|
2019-11-08 02:09:39 +09:00
|
|
|
chart = Chart.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert chart.position == self.position
|
|
|
|
assert chart.progress == self.progress
|
|
|
|
assert chart.listeners == self.listeners
|
|
|
|
assert chart.shift == self.shift
|
|
|
|
|
|
|
|
def test_de_json_all(self, client, track_id):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'position': self.position,
|
|
|
|
'progress': self.progress,
|
|
|
|
'listeners': self.listeners,
|
|
|
|
'shift': self.shift,
|
|
|
|
'bg_color': self.bg_color,
|
|
|
|
'track_id': track_id.to_dict(),
|
|
|
|
}
|
2019-11-08 02:09:39 +09:00
|
|
|
chart = Chart.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert chart.position == self.position
|
|
|
|
assert chart.progress == self.progress
|
|
|
|
assert chart.listeners == self.listeners
|
|
|
|
assert chart.shift == self.shift
|
|
|
|
assert chart.track_id == track_id
|
2020-05-16 04:41:30 +09:00
|
|
|
assert chart.bg_color == self.bg_color
|
2019-11-08 02:09:39 +09:00
|
|
|
|
|
|
|
def test_equality(self):
|
Добавлены основные тесты для следующих классов: Album, Artist, Chart, Counts, Genre, Label, PermissionAlerts, PromoCodeStatus, Restrictions, Settings, Station, StatuonResult, Status, Track.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен restrictions.py.
Исправлен баг в .to_dict() методе, связанный с десериализцией объектов списков и словарей.
2019-11-09 00:24:54 +09:00
|
|
|
a = Chart(self.position, self.progress, self.listeners, self.shift)
|
|
|
|
b = Chart(10, self.progress, self.listeners, self.shift)
|
|
|
|
c = Chart(self.position, self.progress, 10, self.shift)
|
|
|
|
d = Chart(self.position, self.progress, self.listeners, self.shift)
|
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
assert a == d
|