Merge "add mongo index names"
This commit is contained in:
commit
2b92c67c9a
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user