Beispiel #1
0
    def setUp(self):
        class Person(micromodels.Model):
            name = micromodels.CharField()
            age = micromodels.IntegerField()

        self.Person = Person
        self.data = {'name': 'Eric', 'age': 18}
        self.json_data = json.dumps(self.data)
Beispiel #2
0
    def setUp(self):
        class Person(micromodels.Model):
            name = micromodels.CharField()
            age = micromodels.IntegerField()

        self.Person = Person
        self.data = {'name': 'Eric', 'age': 18}
        self.json_data = json.dumps(self.data)
Beispiel #3
0
    def setUp(self):
        class Person(micromodels.Model):
            name = micromodels.CharField()
            age = micromodels.IntegerField()

        self.Person = Person
        self.data = {"name": "Eric", "age": 18}
        self.json_data = json.dumps(self.data)
Beispiel #4
0
    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.dumps(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.loads(instance.to_json())["time"], instance.time.isoformat())
Beispiel #5
0
    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.dumps(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.loads(instance.to_json())['time'],
                         instance.time.isoformat())