test_shot_event.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import pytest
  2. from yandex_music import ShotEvent
  3. @pytest.fixture(scope='class')
  4. def shot_event(shot):
  5. return ShotEvent(TestShotType.event_id, [shot])
  6. class TestShotType:
  7. event_id = '5e25fb2c0cf28e741cb996eb'
  8. def test_expected_values(self, shot_event, shot):
  9. assert shot_event.event_id == self.event_id
  10. assert shot_event.shots == [shot]
  11. def test_de_json_none(self, client):
  12. assert ShotEvent.de_json({}, client) is None
  13. def test_de_json_required(self, client, shot):
  14. json_dict = {'event_id': self.event_id, 'shots': [shot.to_dict()]}
  15. shot_event = ShotEvent.de_json(json_dict, client)
  16. assert shot_event.event_id == self.event_id
  17. assert shot_event.shots == [shot]
  18. def test_de_json_all(self, client, shot):
  19. json_dict = {'event_id': self.event_id, 'shots': [shot.to_dict()]}
  20. shot_event = ShotEvent.de_json(json_dict, client)
  21. assert shot_event.event_id == self.event_id
  22. assert shot_event.shots == [shot]
  23. def test_equality(self, shot):
  24. a = ShotEvent(self.event_id, [shot])
  25. b = ShotEvent('', [shot])
  26. c = ShotEvent(self.event_id, [])
  27. d = ShotEvent(self.event_id, [shot])
  28. assert a != b != c != d
  29. assert hash(a) != hash(b) != hash(c) != hash(d)
  30. assert a is not b is not c is not d
  31. assert a == d
  32. assert hash(a) == hash(d)