test_station_tracks_result.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import pytest
  2. from yandex_music import StationTracksResult
  3. @pytest.fixture(scope='class')
  4. def station_tracks_result(id_, sequence):
  5. return StationTracksResult(id_, [sequence], TestStationTracksResult.batch_id, TestStationTracksResult.pumpkin)
  6. class TestStationTracksResult:
  7. batch_id = '1573227402825981-2727432063278102211'
  8. pumpkin = False
  9. def test_expected_values(self, station_tracks_result, id_, sequence):
  10. assert station_tracks_result.id == id_
  11. assert station_tracks_result.sequence == [sequence]
  12. assert station_tracks_result.batch_id == self.batch_id
  13. assert station_tracks_result.pumpkin == self.pumpkin
  14. def test_de_json_none(self, client):
  15. assert StationTracksResult.de_json({}, client) is None
  16. def test_de_json_required(self, client, id_, sequence):
  17. json_dict = {
  18. 'id': id_.to_dict(),
  19. 'sequence': [sequence.to_dict()],
  20. 'batch_id': self.batch_id,
  21. 'pumpkin': self.pumpkin,
  22. }
  23. station_tracks_result = StationTracksResult.de_json(json_dict, client)
  24. assert station_tracks_result.id == id_
  25. assert station_tracks_result.sequence == [sequence]
  26. assert station_tracks_result.batch_id == self.batch_id
  27. assert station_tracks_result.pumpkin == self.pumpkin
  28. def test_de_json_all(self, client, id_, sequence):
  29. json_dict = {
  30. 'id': id_.to_dict(),
  31. 'sequence': [sequence.to_dict()],
  32. 'batch_id': self.batch_id,
  33. 'pumpkin': self.pumpkin,
  34. }
  35. station_tracks_result = StationTracksResult.de_json(json_dict, client)
  36. assert station_tracks_result.id == id_
  37. assert station_tracks_result.sequence == [sequence]
  38. assert station_tracks_result.batch_id == self.batch_id
  39. assert station_tracks_result.pumpkin == self.pumpkin
  40. def test_equality(self, id_, sequence):
  41. a = StationTracksResult(id_, sequence, self.batch_id, self.pumpkin)
  42. b = StationTracksResult(id_, sequence, '', False)
  43. c = StationTracksResult(id_, sequence, self.batch_id, self.pumpkin)
  44. assert a != b
  45. assert hash(a) != hash(b)
  46. assert a is not b
  47. assert a == c