test_link.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from yandex_music import Link
  2. class TestLink:
  3. title = 'emmure'
  4. href = 'https://www.facebook.com/emmure'
  5. type = 'social'
  6. social_network = 'facebook'
  7. def test_expected_values(self, link):
  8. assert link.title == self.title
  9. assert link.href == self.href
  10. assert link.type == self.type
  11. assert link.social_network == self.social_network
  12. def test_de_json_none(self, client):
  13. assert Link.de_json({}, client) is None
  14. def test_de_list_none(self, client):
  15. assert Link.de_list([], client) == []
  16. def test_de_json_required(self, client):
  17. json_dict = {'title': self.title, 'href': self.href, 'type': self.type}
  18. link = Link.de_json(json_dict, client)
  19. assert link.title == self.title
  20. assert link.href == self.href
  21. assert link.type == self.type
  22. def test_de_json_all(self, client):
  23. json_dict = {'title': self.title, 'href': self.href, 'type': self.type, 'social_network': self.social_network}
  24. link = Link.de_json(json_dict, client)
  25. assert link.title == self.title
  26. assert link.href == self.href
  27. assert link.type == self.type
  28. assert link.social_network == self.social_network
  29. def test_equality(self):
  30. a = Link(self.title, self.href, self.type, self.social_network)
  31. b = Link(self.title, '', self.type, self.social_network)
  32. c = Link(self.title, self.href, '', self.social_network)
  33. d = Link(self.title, self.href, self.type, self.social_network)
  34. assert a != b != c
  35. assert hash(a) != hash(b) != hash(c)
  36. assert a is not b is not c
  37. assert a == d