def test_equality(self, value): a = Enum(self.type, self.name, [value]) b = Enum(self.type, '', [value]) c = Enum(self.type, self.name, [value]) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def test_de_json_all(self, client, value): json_dict = {'type': self.type, 'name': self.name, 'possible_values': [value.to_dict()]} enum = Enum.de_json(json_dict, client) assert enum.type == self.type assert enum.name == self.name assert enum.possible_values == [value]
def de_json(cls, data, client): if not data: return None data = super(Restrictions, cls).de_json(data, client) from yandex_music import Enum, DiscreteScale for key, value in data.items(): restriction_type = data[key].get('type') data[key] = Enum.de_json(data[key], client) if restriction_type == 'enum'\ else DiscreteScale.de_json(data[key], client) return cls(client=client, **data)
def enum(value): return Enum(TestEnum.type, TestEnum.name, [value])
def test_de_json_none(self, client): assert Enum.de_json({}, client) is None