Merge "add mongo index names"

This commit is contained in:
Jenkins 2012-11-01 12:28:54 +00:00 committed by Gerrit Code Review
commit 2b92c67c9a
2 changed files with 10 additions and 2 deletions

View File

@ -191,14 +191,14 @@ class Connection(base.Connection):
self.db.resource.ensure_index([
(primary, pymongo.ASCENDING),
('source', pymongo.ASCENDING),
])
], name='resource_idx')
self.db.meter.ensure_index([
('resource_id', pymongo.ASCENDING),
(primary, pymongo.ASCENDING),
('counter_name', pymongo.ASCENDING),
('timestamp', pymongo.ASCENDING),
('source', pymongo.ASCENDING),
])
], name='meter_idx')
return
def _get_connection(self, opts):

View File

@ -141,6 +141,14 @@ class MongoDBEngineTestBase(unittest.TestCase):
self.conn.drop_database(self.DBNAME)
class IndexTest(MongoDBEngineTestBase):
def test_indexes_exist(self):
# ensure_index returns none if index already exists
assert not self.db.resource.ensure_index('foo', name='resource_idx')
assert not self.db.meter.ensure_index('foo', name='meter_idx')
class UserTest(MongoDBEngineTestBase):
def test_new_user(self):