test_chart_item.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from yandex_music import ChartItem
  2. class TestChartItem:
  3. def test_expected_values(self, chart_item, track, chart):
  4. assert chart_item.track == track
  5. assert chart_item.chart == chart
  6. def test_de_json_none(self, client):
  7. assert ChartItem.de_json({}, client) is None
  8. def test_de_list_none(self, client):
  9. assert ChartItem.de_list([], client) == []
  10. def test_de_json_required(self, client, track, chart):
  11. json_dict = {'track': track.to_dict(), 'chart': chart.to_dict()}
  12. chart_item = ChartItem.de_json(json_dict, client)
  13. assert chart_item.track == track
  14. assert chart_item.chart == chart
  15. def test_de_json_all(self, client, track, chart):
  16. json_dict = {'track': track.to_dict(), 'chart': chart.to_dict()}
  17. chart_item = ChartItem.de_json(json_dict, client)
  18. assert chart_item.track == track
  19. assert chart_item.chart == chart
  20. def test_equality(self, track, chart):
  21. a = ChartItem(track, chart)
  22. b = ChartItem(None, chart)
  23. c = ChartItem(track, chart)
  24. assert a != b
  25. assert hash(a) != hash(b)
  26. assert a is not b
  27. assert a == c