def test_from_dict_return_valid_dict(self): obj1 = Field(name="Price", type=FieldType.Integer, value=100, displayName="Цена") obj1_dict = obj1.to_dict() clean_dict = loads(dumps(obj1_dict, ensure_ascii=False), encoding="utf-8") obj2 = Field().from_dict(clean_dict) obj2_dict = obj2.to_dict() self.assertDictEqual(obj1_dict, obj2_dict)
def test_to_dict_convertable_to_dict(self): obj = Field(name="Price", type=FieldType.Integer, value=100, displayName="Цена") expected = dumps( dict(fn="Price", ft=FieldType.Integer.name, fv=100, fdn="Цена")) self.assertEqual(dumps(obj.to_dict()), expected)
def test_to_dict_return_valid_dict(self): obj = Field(name="Price", type=FieldType.Integer, value=100, displayName="Цена") expected = dict(fn="Price", ft=FieldType.Integer.name, fv=100, fdn="Цена") self.assertEqual(obj.to_dict(), expected)
def test_to_dict_returns_none_when_value_not_set(self): obj = Field() self.assertEqual(obj.to_dict(), None)