test_chart_info_menu_item.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from yandex_music import ChartInfoMenuItem
  2. class TestChartInfoMenuItem:
  3. title = 'Россия'
  4. url = 'russia'
  5. selected = True
  6. def test_expected_values(self, chart_info_menu_item):
  7. assert chart_info_menu_item.title == self.title
  8. assert chart_info_menu_item.url == self.url
  9. assert chart_info_menu_item.selected == self.selected
  10. def test_de_json_none(self, client):
  11. assert ChartInfoMenuItem.de_json({}, client) is None
  12. def test_de_json_required(self, client):
  13. json_dict = {
  14. 'title': self.title,
  15. 'url': self.url,
  16. }
  17. chart_info_menu_item = ChartInfoMenuItem.de_json(json_dict, client)
  18. assert chart_info_menu_item.title == self.title
  19. assert chart_info_menu_item.url == self.url
  20. def test_de_json_all(self, client):
  21. json_dict = {
  22. 'title': self.title,
  23. 'url': self.url,
  24. 'selected': self.selected,
  25. }
  26. chart_info_menu_item = ChartInfoMenuItem.de_json(json_dict, client)
  27. assert chart_info_menu_item.title == self.title
  28. assert chart_info_menu_item.url == self.url
  29. assert chart_info_menu_item.selected == self.selected
  30. def test_equality(self):
  31. a = ChartInfoMenuItem(self.title, self.url, self.selected)
  32. b = ChartInfoMenuItem(self.title, 'no_url', self.selected)
  33. c = ChartInfoMenuItem(self.title, self.url, self.selected)
  34. assert a != b
  35. assert hash(a) != hash(b)
  36. assert a is not b
  37. assert a == c