-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
test_station.py
86 lines (75 loc) · 3.53 KB
/
test_station.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
78
79
80
81
82
83
84
85
86
from yandex_music import Station
class TestStation:
name = 'На вашей волне'
id_for_from = 'user-561231028'
full_image_url = 'avatars.yandex.net/get-music-misc/30221/rotor-activity-sex-full-image-3sv6j/%%'
mts_full_image_url = 'avatars.yandex.net/get-music-misc/2413828/rotor-activity-sex-mts-full-image-sYtDD/%%'
def test_expected_values(self, station, id_, icon, restrictions):
assert station.id == id_
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
assert station.full_image_url == self.full_image_url
assert station.mts_full_image_url == self.mts_full_image_url
assert station.parent_id == id_
def test_de_json_none(self, client):
assert Station.de_json({}, client) is None
def test_de_json_required(self, client, id_, icon, restrictions):
json_dict = {
'id': id_.to_dict(),
'name': self.name,
'icon': icon.to_dict(),
'mts_icon': icon.to_dict(),
'geocell_icon': icon.to_dict(),
'id_for_from': self.id_for_from,
'restrictions': restrictions.to_dict(),
'restrictions2': restrictions.to_dict(),
}
station = Station.de_json(json_dict, client)
assert station.id == id_
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
def test_de_json_all(self, client, id_, icon, restrictions):
json_dict = {
'id': id_.to_dict(),
'name': self.name,
'icon': icon.to_dict(),
'mts_icon': icon.to_dict(),
'geocell_icon': icon.to_dict(),
'id_for_from': self.id_for_from,
'restrictions': restrictions.to_dict(),
'restrictions2': restrictions.to_dict(),
'parent_id': id_.to_dict(),
'full_image_url': self.full_image_url,
'mts_full_image_url': self.mts_full_image_url,
}
station = Station.de_json(json_dict, client)
assert station.id == id_
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
assert station.full_image_url == self.full_image_url
assert station.mts_full_image_url == self.mts_full_image_url
assert station.parent_id == id_
def test_equality(self, id_, icon, restrictions):
a = Station(id_, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
b = Station(id_, self.name, None, icon, icon, self.id_for_from, restrictions, restrictions)
c = Station(id_, '', icon, icon, icon, self.id_for_from, restrictions, restrictions)
d = Station(id_, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d