test_counts.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from yandex_music import Counts
  2. class TestCounts:
  3. tracks = 94
  4. direct_albums = 9
  5. also_albums = 0
  6. also_tracks = 0
  7. def test_expected_values(self, counts):
  8. assert counts.tracks == self.tracks
  9. assert counts.direct_albums == self.direct_albums
  10. assert counts.also_albums == self.also_albums
  11. assert counts.also_tracks == self.also_tracks
  12. def test_de_json_none(self, client):
  13. assert Counts.de_json({}, client) is None
  14. def test_de_json_required(self, client):
  15. json_dict = {
  16. 'tracks': self.tracks,
  17. 'direct_albums': self.direct_albums,
  18. 'also_albums': self.also_albums,
  19. 'also_tracks': self.also_tracks,
  20. }
  21. counts = Counts.de_json(json_dict, client)
  22. assert counts.tracks == self.tracks
  23. assert counts.direct_albums == self.direct_albums
  24. assert counts.also_albums == self.also_albums
  25. assert counts.also_tracks == self.also_tracks
  26. def test_de_json_all(self, client):
  27. json_dict = {
  28. 'tracks': self.tracks,
  29. 'direct_albums': self.direct_albums,
  30. 'also_albums': self.also_albums,
  31. 'also_tracks': self.also_tracks,
  32. }
  33. counts = Counts.de_json(json_dict, client)
  34. assert counts.tracks == self.tracks
  35. assert counts.direct_albums == self.direct_albums
  36. assert counts.also_albums == self.also_albums
  37. assert counts.also_tracks == self.also_tracks
  38. def test_equality(self):
  39. a = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
  40. b = Counts(40, self.direct_albums, 30, self.also_tracks)
  41. c = Counts(self.tracks, self.direct_albums, 10, 10)
  42. d = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
  43. assert a != b != c
  44. assert hash(a) != hash(b) != hash(c)
  45. assert a is not b is not c
  46. assert a == d