test_enum.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from yandex_music import Enum
  2. class TestEnum:
  3. type = 'enum'
  4. name = 'Язык'
  5. def test_expected_values(self, enum, value):
  6. assert enum.type == self.type
  7. assert enum.name == self.name
  8. assert enum.possible_values == [value]
  9. def test_de_json_none(self, client):
  10. assert Enum.de_json({}, client) is None
  11. def test_de_json_required(self, client, value):
  12. json_dict = {'type': self.type, 'name': self.name, 'possible_values': [value.to_dict()]}
  13. enum = Enum.de_json(json_dict, client)
  14. assert enum.type == self.type
  15. assert enum.name == self.name
  16. assert enum.possible_values == [value]
  17. def test_de_json_all(self, client, value):
  18. json_dict = {'type': self.type, 'name': self.name, 'possible_values': [value.to_dict()]}
  19. enum = Enum.de_json(json_dict, client)
  20. assert enum.type == self.type
  21. assert enum.name == self.name
  22. assert enum.possible_values == [value]
  23. def test_equality(self, value):
  24. a = Enum(self.type, self.name, [value])
  25. b = Enum(self.type, '', [value])
  26. c = Enum(self.type, self.name, [value])
  27. assert a != b
  28. assert hash(a) != hash(b)
  29. assert a is not b
  30. assert a == c