Skip to content

Commit

Permalink
Merge "Refactor auxiliary methods for MongoDB unit tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 17, 2014
2 parents c77b747 + 67d9369 commit e89b390
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions tests/unit/queues/storage/test_impl_mongodb.py
Expand Up @@ -35,12 +35,17 @@
from marconi.tests.queues.storage import base


def _cleanup_databases(controller):
databases = (controller.driver.message_databases +
[controller.driver.queues_database])
class MongodbDBSetup(testing.TestBase):
def _purge_databases(self):
databases = (self.driver.message_databases +
[self.driver.queues_database])

for db in databases:
controller.driver.connection.drop_database(db)
for db in databases:
self.driver.connection.drop_database(db)

def _prepare_conf(self):
self.config(options.MONGODB_GROUP,
database=uuid.uuid4().hex)


class MongodbUtilsTest(testing.TestBase):
Expand Down Expand Up @@ -133,9 +138,6 @@ class MongodbDriverTest(testing.TestBase):

config_file = 'wsgi_mongodb.conf'

def _purge_databases(self):
_cleanup_databases(self)

def test_db_instance(self):
cache = oslo_cache.get_cache()
driver = mongodb.DataDriver(self.conf, cache)
Expand All @@ -155,13 +157,6 @@ class MongodbQueueTests(base.QueueControllerTest):
config_file = 'wsgi_mongodb.conf'
controller_class = controllers.QueueController

def _purge_databases(self):
_cleanup_databases(self)

def _prepare_conf(self):
self.config(options.MONGODB_GROUP,
database=uuid.uuid4().hex)

def test_indexes(self):
collection = self.controller._collection
indexes = collection.index_information()
Expand Down Expand Up @@ -198,13 +193,6 @@ class MongodbMessageTests(base.MessageControllerTest):
# NOTE(kgriffs): MongoDB's TTL scavenger only runs once a minute
gc_interval = 60

def _purge_databases(self):
_cleanup_databases(self)

def _prepare_conf(self):
self.config(options.MONGODB_GROUP,
database=uuid.uuid4().hex)

def test_indexes(self):
for collection in self.controller._collections:
indexes = collection.index_information()
Expand Down Expand Up @@ -349,13 +337,6 @@ class MongodbClaimTests(base.ClaimControllerTest):
config_file = 'wsgi_mongodb.conf'
controller_class = controllers.ClaimController

def _purge_databases(self):
_cleanup_databases(self)

def _prepare_conf(self):
self.config(options.MONGODB_GROUP,
database=uuid.uuid4().hex)

def test_claim_doesnt_exist(self):
"""Verifies that operations fail on expired/missing claims.
Expand Down

0 comments on commit e89b390

Please sign in to comment.