test_supplement.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import pytest
  2. from yandex_music import Supplement
  3. @pytest.fixture(scope='class')
  4. def supplement(lyrics, video_supplement):
  5. return Supplement(
  6. TestSupplement.id, lyrics, [video_supplement], TestSupplement.radio_is_available, TestSupplement.description
  7. )
  8. class TestSupplement:
  9. id = 103844
  10. radio_is_available = False
  11. description = (
  12. '"ИНТЕРВЬЮ С КОМИКОМ" - это не юмористический проект. Это разговор о жизни, творчестве, интересах, '
  13. 'целях и приоритетах, о том, кто как живет и почему.\nНовый проект Дмитрия Романова, в котором он '
  14. 'берет интервью.\n Гость выпуска - комик Нурлан Сабуров'
  15. )
  16. def test_expected_values(self, supplement, lyrics, video_supplement):
  17. assert supplement.id == self.id
  18. assert supplement.lyrics == lyrics
  19. assert supplement.videos == [video_supplement]
  20. assert supplement.radio_is_available == self.radio_is_available
  21. assert supplement.description == self.description
  22. def test_de_json_none(self, client):
  23. assert Supplement.de_json({}, client) is None
  24. def test_de_json_required(self, client, lyrics, video_supplement):
  25. json_dict = {'id': self.id, 'lyrics': lyrics.to_dict(), 'videos': [video_supplement.to_dict()]}
  26. supplement = Supplement.de_json(json_dict, client)
  27. assert supplement.id == self.id
  28. assert supplement.lyrics == lyrics
  29. assert supplement.videos == [video_supplement]
  30. def test_de_json_all(self, client, lyrics, video_supplement):
  31. json_dict = {
  32. 'id': self.id,
  33. 'lyrics': lyrics.to_dict(),
  34. 'videos': [video_supplement.to_dict()],
  35. 'radio_is_available': self.radio_is_available,
  36. 'description': self.description,
  37. }
  38. supplement = Supplement.de_json(json_dict, client)
  39. assert supplement.id == self.id
  40. assert supplement.lyrics == lyrics
  41. assert supplement.videos == [video_supplement]
  42. assert supplement.radio_is_available == self.radio_is_available
  43. assert supplement.description == self.description
  44. def test_equality(self, lyrics, video_supplement):
  45. a = Supplement(self.id, lyrics, [video_supplement])
  46. b = Supplement(self.id, None, [video_supplement])
  47. c = Supplement(self.id, lyrics, [video_supplement])
  48. assert a != b
  49. assert hash(a) != hash(b)
  50. assert a is not b
  51. assert a == c