test_permissions.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from yandex_music import Permissions
  2. class TestPermissions:
  3. until = '2019-11-07T23:53:55+00:00'
  4. values = ['landing-play', 'feed-play', 'mix-play']
  5. default = ['landing-play', 'feed-play', 'mix-play']
  6. def test_expected_values(self, permissions):
  7. assert permissions.until == self.until
  8. assert permissions.values == self.values
  9. assert permissions.default == self.default
  10. def test_de_json_none(self, client):
  11. assert Permissions.de_json({}, client) is None
  12. def test_de_json_required(self, client):
  13. json_dict = {'until': self.until, 'values': self.values, 'default': self.default}
  14. permissions = Permissions.de_json(json_dict, client)
  15. assert permissions.until == self.until
  16. assert permissions.values == self.values
  17. assert permissions.default == self.default
  18. def test_de_json_all(self, client):
  19. json_dict = {'until': self.until, 'values': self.values, 'default': self.default}
  20. permissions = Permissions.de_json(json_dict, client)
  21. assert permissions.until == self.until
  22. assert permissions.values == self.values
  23. assert permissions.default == self.default
  24. def test_equality(self):
  25. a = Permissions(self.until, self.values, self.default)
  26. b = Permissions('', self.values, self.default)
  27. c = Permissions(self.until, self.values, self.default)
  28. assert a != b
  29. assert hash(a) != hash(b)
  30. assert a is not b
  31. assert a == c