do not run tests if mongodb connect fails

This commit is contained in:
Chris Meyers
2015-04-03 12:00:56 -04:00
parent c03cef022d
commit 35e1c19fc2
6 changed files with 30 additions and 16 deletions

View File

@@ -26,7 +26,7 @@ from django.test.client import Client
from django.test.utils import override_settings
# MongoEngine
from mongoengine.connection import get_db
from mongoengine.connection import get_db, ConnectionError
# AWX
from awx.main.models import * # noqa
@@ -43,6 +43,15 @@ TEST_PLAYBOOK = '''- hosts: mygroup
command: test 1 = 1
'''
class MongoDBRequired(django.test.TestCase):
def setUp(self):
# Drop mongo database
try:
self.db = get_db()
self.db.connection.drop_database(settings.MONGO_DB)
except ConnectionError as e:
self.skipTest('MongoDB connection failed')
class QueueTestMixin(object):
def start_queue(self):
self.start_redis()
@@ -88,10 +97,6 @@ class BaseTestMixin(QueueTestMixin):
def setUp(self):
super(BaseTestMixin, self).setUp()
# Drop mongo database
self.db = get_db()
self.db.connection.drop_database(settings.MONGO_DB)
self.object_ctr = 0
# Save sys.path before tests.
self._sys_path = [x for x in sys.path]