def test_serialize(self):
        child = ChildDocument(charfield='bar')
        child.save()
        parent = ParentDocument(title='foo', subdocument=child, subschema=ChildSchema(ct=ContentType.objects.all()[0]))
        assert parent.natural_key
        assert '@natural_key' in parent._primitive_data
        data = parent.to_portable_primitive(parent)
        self.assertTrue(isinstance(data['subschema']['ct'], tuple), str(data))
        self.assertTrue(isinstance(data['subdocument'], dict), "Did not give a natural key: %s" % data['subdocument'])
        self.assertTrue('@natural_key' in data, str(data))
        result = self.serializer.serialize([child, parent])
        self.assertEqual(len(result), 2)
        entry = result[1]
        self.assertTrue('fields' in entry)
        self.assertEqual(len(entry['fields']), 3, str(entry))
        del data['@natural_key']
        del data['@natural_key_hash']
        self.assertEqual(entry['fields'], data)
dataset/ETHPy150Open zbyte64/django-dockit/dockit/tests/serializers/python_tests.py/PythonSerializerTestCase.test_serialize/original