test_icon.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from yandex_music import Icon
  2. class TestIcon:
  3. background_color = '#ff6665'
  4. image_url = 'avatars.yandex.net/get-music-misc/34161/rotor-genre-pop-icon/%%'
  5. def test_expected_values(self, icon):
  6. assert icon.background_color == self.background_color
  7. assert icon.image_url == self.image_url
  8. def test_de_json_none(self, client):
  9. assert Icon.de_json({}, client) is None
  10. def test_de_json_required(self, client):
  11. json_dict = {'background_color': self.background_color, 'image_url': self.image_url}
  12. icon = Icon.de_json(json_dict, client)
  13. assert icon.background_color == self.background_color
  14. assert icon.image_url == self.image_url
  15. def test_de_json_all(self, client):
  16. json_dict = {'background_color': self.background_color, 'image_url': self.image_url}
  17. icon = Icon.de_json(json_dict, client)
  18. assert icon.background_color == self.background_color
  19. assert icon.image_url == self.image_url
  20. def test_equality(self):
  21. a = Icon(self.background_color, self.image_url)
  22. b = Icon('#000000', self.image_url)
  23. c = Icon(self.background_color, '')
  24. d = Icon(self.background_color, self.image_url)
  25. assert a != b != c
  26. assert hash(a) != hash(b) != hash(c)
  27. assert a is not b is not c
  28. assert a == d