test_rotor_settings.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from yandex_music import RotorSettings
  2. class TestRotorSettings:
  3. language = 'not-russian'
  4. diversity = 'default'
  5. mood = 2
  6. energy = 2
  7. mood_energy = 'fun'
  8. def test_expected_values(self, rotor_settings):
  9. assert rotor_settings.language == self.language
  10. assert rotor_settings.diversity == self.diversity
  11. assert rotor_settings.mood == self.mood
  12. assert rotor_settings.energy == self.energy
  13. assert rotor_settings.mood_energy == self.mood_energy
  14. def test_de_json_none(self, client):
  15. assert RotorSettings.de_json({}, client) is None
  16. def test_de_json_required(self, client):
  17. json_dict = {'language': self.language, 'diversity': self.diversity}
  18. rotor_settings = RotorSettings.de_json(json_dict, client)
  19. assert rotor_settings.language == self.language
  20. assert rotor_settings.diversity == self.diversity
  21. def test_de_json_all(self, client):
  22. json_dict = {
  23. 'language': self.language,
  24. 'diversity': self.diversity,
  25. 'mood': self.mood,
  26. 'energy': self.energy,
  27. 'mood_energy': self.mood_energy,
  28. }
  29. rotor_settings = RotorSettings.de_json(json_dict, client)
  30. assert rotor_settings.language == self.language
  31. assert rotor_settings.diversity == self.diversity
  32. assert rotor_settings.mood == self.mood
  33. assert rotor_settings.energy == self.energy
  34. assert rotor_settings.mood_energy == self.mood_energy
  35. def test_equality(self):
  36. a = RotorSettings(self.language, self.diversity)
  37. b = RotorSettings('', self.diversity)
  38. c = RotorSettings(self.language, self.diversity)
  39. assert a != b
  40. assert hash(a) != hash(b)
  41. assert a is not b
  42. assert a == c