Updated geo_index checking to be recursive

Fixes #127 - Embedded Documents can declare geo indexes and have
them created automatically
This commit is contained in:
Ross Lawley
2011-06-20 15:41:23 +01:00
parent e3cd398f70
commit 08ba51f714
4 changed files with 129 additions and 98 deletions

View File

@@ -1312,6 +1312,27 @@ class FieldTest(unittest.TestCase):
Event.drop_collection()
def test_geo_embedded_indexes(self):
"""Ensure that indexes are created automatically for GeoPointFields on
embedded documents.
"""
class Venue(EmbeddedDocument):
location = GeoPointField()
name = StringField()
class Event(Document):
title = StringField()
venue = EmbeddedDocumentField(Venue)
Event.drop_collection()
venue = Venue(name="Double Door", location=[41.909889, -87.677137])
event = Event(title="Coltrane Motion", venue=venue)
event.save()
info = Event.objects._collection.index_information()
self.assertTrue(u'location_2d' in info)
self.assertTrue(info[u'location_2d']['key'] == [(u'location', u'2d')])
def test_ensure_unique_default_instances(self):
"""Ensure that every field has it's own unique default instance."""
class D(Document):