-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
test_chart_info.py
77 lines (64 loc) · 2.79 KB
/
test_chart_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from yandex_music import ChartInfo
class TestChartInfo:
id = 'KpXst7X4'
type = 'chart'
type_for_from = 'chart'
title = 'Треки, популярные на Яндекс.Музыке прямо сейчас'
chart_description = 'Слушателей за день'
def test_expected_values(self, chart_info, chart_info_menu, playlist):
assert chart_info.id == self.id
assert chart_info.type == self.type
assert chart_info.type_for_from == self.type_for_from
assert chart_info.title == self.title
assert chart_info.chart == playlist
assert chart_info.menu == chart_info_menu
def test_de_json_none(self, client):
assert ChartInfo.de_json({}, client) is None
def test_de_json_required(self, playlist, chart_info_menu, client):
json_dict = {
'id': self.id,
'type': self.type,
'type_for_from': self.type_for_from,
'title': self.title,
'chart_description': self.chart_description,
'menu': chart_info_menu.to_dict(),
'chart': playlist.to_dict(),
}
chart_info = ChartInfo.de_json(json_dict, client)
assert chart_info.id == self.id
assert chart_info.type == self.type
assert chart_info.type_for_from == self.type_for_from
assert chart_info.title == self.title
assert chart_info.chart_description == self.chart_description
def test_de_json_all(self, client, playlist, chart_info_menu):
json_dict = {
'id': self.id,
'type': self.type,
'type_for_from': self.type_for_from,
'title': self.title,
'chart_description': self.chart_description,
'menu': chart_info_menu.to_dict(),
'chart': playlist.to_dict(),
}
chart_info = ChartInfo.de_json(json_dict, client)
assert chart_info.id == self.id
assert chart_info.type == self.type
assert chart_info.type_for_from == self.type_for_from
assert chart_info.title == self.title
assert chart_info.chart_description == self.chart_description
assert chart_info.menu == chart_info_menu
assert chart_info.chart == playlist
def test_equality(self, playlist, chart_info_menu):
a = ChartInfo(
self.id, self.type, self.type_for_from, self.title, self.chart_description, chart_info_menu, playlist
)
b = ChartInfo(
'no_id', self.type, self.type_for_from, self.title, self.chart_description, chart_info_menu, playlist
)
c = ChartInfo(
self.id, self.type, self.type_for_from, self.title, self.chart_description, chart_info_menu, playlist
)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c