test_context.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from yandex_music import Context
  2. class TestContext:
  3. type_ = 'playlist'
  4. id_ = '503646255:69814820'
  5. description = 'Playlist of the Day'
  6. def test_expected_values(self, context):
  7. assert context.type == self.type_
  8. assert context.id == self.id_
  9. assert context.description == self.description
  10. def test_de_json_none(self, client):
  11. assert Context.de_json({}, client) is None
  12. def test_de_json_required(self, client):
  13. json_dict = {'type': self.type_}
  14. context = Context.de_json(json_dict, client)
  15. assert context.type == self.type_
  16. def test_de_json_all(self, client, track_id):
  17. json_dict = {'type': self.type_, 'id': self.id_, 'description': self.description}
  18. context = Context.de_json(json_dict, client)
  19. assert context.type == self.type_
  20. assert context.id == self.id_
  21. assert context.description == self.description
  22. def test_equality(self):
  23. a = Context(self.type_)
  24. b = Context('')
  25. c = Context(self.type_)
  26. assert a != b
  27. assert hash(a) != hash(b)
  28. assert a is not b
  29. assert a == c