test_tag.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from yandex_music import Tag
  2. class TestTag:
  3. id_ = '5795ce8f77d30f7fda41bca0'
  4. value = 'вечные хиты'
  5. name = 'Вечные хиты'
  6. og_description = ''
  7. og_image = 'https://avatars.yandex.net/get-music-misc/2419084/PlaylistTag.5ea7e04c71ca3b6c946af177.ru.og/orig'
  8. def test_expected_values(self, tag):
  9. assert tag.id == self.id_
  10. assert tag.value == self.value
  11. assert tag.name == self.name
  12. assert tag.og_description == self.og_description
  13. assert tag.og_image == self.og_image
  14. def test_de_json_none(self, client):
  15. assert Tag.de_json({}, client) is None
  16. def test_de_json_required(self, client):
  17. json_dict = {'id': self.id_, 'value': self.value, 'name': self.name, 'og_description': self.og_description}
  18. tag = Tag.de_json(json_dict, client)
  19. assert tag.id == self.id_
  20. assert tag.value == self.value
  21. assert tag.name == self.name
  22. assert tag.og_description == self.og_description
  23. def test_de_json_all(self, client):
  24. json_dict = {
  25. 'id': self.id_,
  26. 'value': self.value,
  27. 'name': self.name,
  28. 'og_description': self.og_description,
  29. 'og_image': self.og_image,
  30. }
  31. tag = Tag.de_json(json_dict, client)
  32. assert tag.id == self.id_
  33. assert tag.value == self.value
  34. assert tag.name == self.name
  35. assert tag.og_description == self.og_description
  36. assert tag.og_image == self.og_image
  37. def test_equality(self):
  38. a = Tag(self.id_, self.value, self.name, self.og_description)
  39. b = Tag('10b300', self.value, self.name, self.og_description)
  40. c = Tag(self.id_, self.value, '', self.og_description)
  41. d = Tag(self.id_, self.value, self.name, self.og_description)
  42. assert a != b != c
  43. assert hash(a) != hash(b) != hash(c)
  44. assert a is not b is not c
  45. assert a == d