test_dashboard.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import pytest
  2. from yandex_music import Dashboard
  3. @pytest.fixture(scope='class')
  4. def dashboard(station_result):
  5. return Dashboard(TestDashboard.dashboard_id, [station_result], TestDashboard.pumpkin)
  6. class TestDashboard:
  7. dashboard_id = '1573229923780896-4168369461406125948'
  8. pumpkin = False
  9. def test_expected_values(self, dashboard, station_result):
  10. assert dashboard.dashboard_id == self.dashboard_id
  11. assert dashboard.stations == [station_result]
  12. assert dashboard.pumpkin == self.pumpkin
  13. def test_de_json_none(self, client):
  14. assert Dashboard.de_json({}, client) is None
  15. def test_de_json_required(self, client, station_result):
  16. json_dict = {'dashboard_id': self.dashboard_id, 'stations': [station_result.to_dict()], 'pumpkin': self.pumpkin}
  17. dashboard = Dashboard.de_json(json_dict, client)
  18. assert dashboard.dashboard_id == self.dashboard_id
  19. assert dashboard.stations == [station_result]
  20. assert dashboard.pumpkin == self.pumpkin
  21. def test_de_json_all(self, client, station_result):
  22. json_dict = {'dashboard_id': self.dashboard_id, 'stations': [station_result.to_dict()], 'pumpkin': self.pumpkin}
  23. dashboard = Dashboard.de_json(json_dict, client)
  24. assert dashboard.dashboard_id == self.dashboard_id
  25. assert dashboard.stations == [station_result]
  26. assert dashboard.pumpkin == self.pumpkin
  27. def test_equality(self, station):
  28. a = Dashboard(self.dashboard_id, [station], self.pumpkin)
  29. b = Dashboard('', [station], True)
  30. c = Dashboard(self.dashboard_id, [station], self.pumpkin)
  31. assert a != b
  32. assert hash(a) != hash(b)
  33. assert a is not b
  34. assert a == c