test_landing.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import pytest
  2. from yandex_music import Landing
  3. @pytest.fixture(scope='class')
  4. def landing(block):
  5. return Landing(TestLanding.pumpkin, TestLanding.content_id, [block])
  6. class TestLanding:
  7. pumpkin = False
  8. content_id = '-1159799446'
  9. def test_expected_values(self, landing, block):
  10. assert landing.pumpkin == self.pumpkin
  11. assert landing.content_id == self.content_id
  12. assert landing.blocks == [block]
  13. def test_de_json_none(self, client):
  14. assert Landing.de_json({}, client) is None
  15. def test_de_json_required(self, client, block):
  16. json_dict = {'pumpkin': self.pumpkin, 'content_id': self.content_id, 'blocks': [block.to_dict()]}
  17. landing = Landing.de_json(json_dict, client)
  18. assert landing.pumpkin == self.pumpkin
  19. assert landing.content_id == self.content_id
  20. assert landing.blocks == [block]
  21. def test_de_json_all(self, client, block):
  22. json_dict = {'pumpkin': self.pumpkin, 'content_id': self.content_id, 'blocks': [block.to_dict()]}
  23. landing = Landing.de_json(json_dict, client)
  24. assert landing.pumpkin == self.pumpkin
  25. assert landing.content_id == self.content_id
  26. assert landing.blocks == [block]
  27. def test_equality(self, block):
  28. a = Landing(self.pumpkin, self.content_id, [block])
  29. b = Landing(self.pumpkin, '', [block])
  30. c = Landing(self.pumpkin, self.content_id, [])
  31. d = Landing(self.pumpkin, self.content_id, [block])
  32. assert a != b != c
  33. assert hash(a) != hash(b) != hash(c)
  34. assert a is not b is not c
  35. assert a == d