def test_extract_document(self): related = RelatedModel.objects.create(qux="qux") test_obj = GrandchildIndexable( foo="Testing", bar=7, baz=datetime.datetime(year=2014, month=4, day=23, hour=9).replace(tzinfo=timezone.utc), related=related ) test_obj.save(index=False) reference_document = { "id": test_obj.pk, "parentindexable_ptr_id": test_obj.pk, "childindexable_ptr_id": test_obj.pk, "polymorphic_ctype_id": test_obj.polymorphic_ctype_id, "foo": "Testing", "bar": 7, "baz": "2014-04-23T09:00:00+00:00", "related_id": related.id } self.assertEqual(reference_document, test_obj.extract_document())