-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
test_play_context.py
55 lines (44 loc) · 1.99 KB
/
test_play_context.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
from yandex_music import PlayContext
class TestPlayContext:
client_ = 'android'
context = 'playlist'
context_item = '503646255:69814820'
def test_expected_values(self, play_context, track_short_old):
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_de_json_none(self, client):
assert PlayContext.de_json({}, client) is None
def test_de_json_required(self, client, track_short_old):
json_dict = {
'client_': self.client_,
'context': self.context,
'context_item': self.context_item,
'tracks': [track_short_old.to_dict()],
}
play_context = PlayContext.de_json(json_dict, client)
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_de_json_all(self, client, track_short_old):
json_dict = {
'client_': self.client_,
'context': self.context,
'context_item': self.context_item,
'tracks': [track_short_old.to_dict()],
}
play_context = PlayContext.de_json(json_dict, client)
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_equality(self, track_short_old):
a = PlayContext(self.client_, self.context, self.context_item, [track_short_old])
b = PlayContext('', self.context, self.context_item, [])
c = PlayContext(self.client_, self.context, self.context_item, [track_short_old])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c