test_restrictions.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from yandex_music import Restrictions
  2. class TestRestrictions:
  3. def test_expected_values(self, restrictions, enum, discrete_scale):
  4. assert restrictions.language == enum
  5. assert restrictions.diversity == enum
  6. assert restrictions.mood == discrete_scale
  7. assert restrictions.energy == discrete_scale
  8. assert restrictions.mood_energy == enum
  9. def test_de_json_none(self, client):
  10. assert Restrictions.de_json({}, client) is None
  11. def test_de_json_required(self, client, enum):
  12. json_dict = {'language': enum.to_dict(), 'diversity': enum.to_dict()}
  13. restrictions = Restrictions.de_json(json_dict, client)
  14. assert restrictions.language == enum
  15. assert restrictions.diversity == enum
  16. def test_de_json_all(self, client, enum, discrete_scale):
  17. json_dict = {
  18. 'language': enum.to_dict(),
  19. 'diversity': enum.to_dict(),
  20. 'mood': discrete_scale.to_dict(),
  21. 'energy': discrete_scale.to_dict(),
  22. 'mood_energy': enum.to_dict(),
  23. }
  24. restrictions = Restrictions.de_json(json_dict, client)
  25. assert restrictions.language == enum
  26. assert restrictions.diversity == enum
  27. assert restrictions.mood == discrete_scale
  28. assert restrictions.energy == discrete_scale
  29. assert restrictions.mood_energy == enum
  30. def test_equality(self, enum, discrete_scale):
  31. a = Restrictions(enum, enum)
  32. b = Restrictions(enum, None)
  33. c = Restrictions(enum, enum)
  34. assert a != b
  35. assert hash(a) != hash(b)
  36. assert a is not b
  37. assert a == c