mirror of
https://github.com/rpkilby/jsonfield.git
synced 2022-02-12 21:18:11 +03:00
Test serialize/deserialize
This commit is contained in:
@@ -155,6 +155,17 @@ class JSONFieldTest(TestCase):
|
||||
pulled = self.json_model.objects.get(id=obj.pk)
|
||||
self.assertEqual(obj.json, pulled.json)
|
||||
|
||||
def test_serialize_deserialize(self):
|
||||
self.json_model.objects.create(json={'foo': 'bar'})
|
||||
|
||||
for f in ['python', 'json', 'xml']:
|
||||
with self.subTest(format=f):
|
||||
data = serialize(f, self.json_model.objects.all())
|
||||
instance, = deserialize(f, data)
|
||||
|
||||
# The actual model instance is accessed as `object`.
|
||||
self.assertEqual(instance.object.json, {'foo': 'bar'})
|
||||
|
||||
def test_default_parameters(self):
|
||||
"""Test providing a default value to the model"""
|
||||
model = JSONModel()
|
||||
|
||||
Reference in New Issue
Block a user