def test_model_type_change_serialization(self): class Event(micromodels.Model): time = micromodels.DateField(format="%Y-%m-%d") data = {'time': '2000-10-31'} json_data = json.encode(data) instance = Event.from_dict(json_data, is_json=True) output = instance.to_dict(serial=True) self.assertEqual(output['time'], instance.time.isoformat()) self.assertEqual(json.decode(instance.to_json())['time'], instance.time.isoformat())
def test_model_reserialization(self): instance = self.Person.from_dict(self.json_data, is_json=True) self.assertEqual(instance.to_json(), self.json_data) instance.name = 'John' self.assertEqual(json.decode(instance.to_json())['name'], 'John')