test_day.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from yandex_music import Day
  2. class TestDay:
  3. day = '2019-11-09'
  4. def test_expected_values(self, day, event, track_with_ads, track):
  5. assert day.day == self.day
  6. assert day.events == [event]
  7. assert day.tracks_to_play_with_ads == [track_with_ads]
  8. assert day.tracks_to_play == [track]
  9. def test_de_json_none(self, client):
  10. assert Day.de_json({}, client) is None
  11. def test_de_list_none(self, client):
  12. assert Day.de_list([], client) == []
  13. def test_de_json_required(self, client, event, track_with_ads, track):
  14. json_dict = {
  15. 'day': self.day,
  16. 'events': [event.to_dict()],
  17. 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
  18. 'tracks_to_play': [track.to_dict()],
  19. }
  20. day = Day.de_json(json_dict, client)
  21. assert day.day == self.day
  22. assert day.events == [event]
  23. assert day.tracks_to_play_with_ads == [track_with_ads]
  24. assert day.tracks_to_play == [track]
  25. def test_de_json_all(self, client, event, track_with_ads, track):
  26. json_dict = {
  27. 'day': self.day,
  28. 'events': [event.to_dict()],
  29. 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
  30. 'tracks_to_play': [track.to_dict()],
  31. }
  32. day = Day.de_json(json_dict, client)
  33. assert day.day == self.day
  34. assert day.events == [event]
  35. assert day.tracks_to_play_with_ads == [track_with_ads]
  36. assert day.tracks_to_play == [track]
  37. def test_equality(self, event, track_with_ads, track):
  38. a = Day(self.day, [event], [track_with_ads], [track])
  39. b = Day('', [event], [track_with_ads], [track])
  40. c = Day(self.day, [event], [track_with_ads], [track])
  41. assert a != b
  42. assert hash(a) != hash(b)
  43. assert a is not b
  44. assert a == c