test_open_graph_data.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from yandex_music import OpenGraphData
  2. class TestOpenGraphData:
  3. title = 'Подкасты недели'
  4. description = (
  5. 'Чтобы собрать для вас этот плейлист, мы должны узнать вас '
  6. 'чуточку поближе. Заходите на Музыку и слушайте больше!'
  7. )
  8. def test_expected_values(self, open_graph_data, cover):
  9. assert open_graph_data.title == self.title
  10. assert open_graph_data.description == self.description
  11. def test_de_json_none(self, client):
  12. assert OpenGraphData.de_json({}, client) is None
  13. def test_de_json_required(self, client, cover):
  14. json_dict = {'title': self.title, 'description': self.description, 'image': cover.to_dict()}
  15. open_graph_data = OpenGraphData.de_json(json_dict, client)
  16. assert open_graph_data.title == self.title
  17. assert open_graph_data.description == self.description
  18. assert open_graph_data.image == cover
  19. def test_de_json_all(self, client, cover):
  20. json_dict = {'title': self.title, 'description': self.description, 'image': cover.to_dict()}
  21. open_graph_data = OpenGraphData.de_json(json_dict, client)
  22. assert open_graph_data.title == self.title
  23. assert open_graph_data.description == self.description
  24. assert open_graph_data.image == cover
  25. def test_equality(self, cover):
  26. a = OpenGraphData(self.title, self.description, cover)
  27. b = OpenGraphData('', self.description, cover)
  28. c = OpenGraphData(self.title, self.description, cover)
  29. assert a != b
  30. assert hash(a) != hash(b)
  31. assert a is not b
  32. assert a == c