-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
test_counts.py
57 lines (46 loc) · 1.92 KB
/
test_counts.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
from yandex_music import Counts
class TestCounts:
tracks = 94
direct_albums = 9
also_albums = 0
also_tracks = 0
def test_expected_values(self, counts):
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_de_json_none(self, client):
assert Counts.de_json({}, client) is None
def test_de_json_required(self, client):
json_dict = {
'tracks': self.tracks,
'direct_albums': self.direct_albums,
'also_albums': self.also_albums,
'also_tracks': self.also_tracks,
}
counts = Counts.de_json(json_dict, client)
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_de_json_all(self, client):
json_dict = {
'tracks': self.tracks,
'direct_albums': self.direct_albums,
'also_albums': self.also_albums,
'also_tracks': self.also_tracks,
}
counts = Counts.de_json(json_dict, client)
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_equality(self):
a = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
b = Counts(40, self.direct_albums, 30, self.also_tracks)
c = Counts(self.tracks, self.direct_albums, 10, 10)
d = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d