From cfd2cbf3dd0c454556524a649204c51f7a6f6a5b Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 21 Jun 2011 16:04:44 -0500 Subject: [PATCH] Make sure we *ONLY* ever kill the test database, EVER. --- mediagoblin/tests/__init__.py | 11 +++++++---- mediagoblin/tests/tools.py | 7 ++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mediagoblin/tests/__init__.py b/mediagoblin/tests/__init__.py index 1f1e23e9..8aec4a96 100644 --- a/mediagoblin/tests/__init__.py +++ b/mediagoblin/tests/__init__.py @@ -16,12 +16,15 @@ from mediagoblin import mg_globals +from mediagoblin.tests.tools import MEDIAGOBLIN_TEST_DB_NAME + def setup_package(): pass def teardown_package(): - if mg_globals.db_connection: - print "Killing db ..." - mg_globals.db_connection.drop_database(mg_globals.database.name) - print "... done" + if ((mg_globals.db_connection + and mg_globals.database.name == MEDIAGOBLIN_TEST_DB_NAME)): + print "Killing db ..." + mg_globals.db_connection.drop_database(MEDIAGOBLIN_TEST_DB_NAME) + print "... done" diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 9e36fc5c..b35d54e0 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -28,7 +28,7 @@ from mediagoblin.decorators import _make_safe from mediagoblin.db.open import setup_connection_and_db_from_config -MEDIAGOBLIN_TEST_DB_NAME = '__mediagoblinunittests__' +MEDIAGOBLIN_TEST_DB_NAME = u'__mediagoblin_tests__' TEST_SERVER_CONFIG = pkg_resources.resource_filename( 'mediagoblin.tests', 'test_paste.ini') TEST_APP_CONFIG = pkg_resources.resource_filename( @@ -78,6 +78,7 @@ def get_test_app(dump_old_app=True): # @@: For now we're dropping collections, but we could also just # collection.remove() ? connection, db = setup_connection_and_db_from_config(app_config) + assert db.name == MEDIAGOBLIN_TEST_DB_NAME collections_to_wipe = [ collection @@ -87,10 +88,6 @@ def get_test_app(dump_old_app=True): for collection in collections_to_wipe: db.drop_collection(collection) - # Don't need these anymore... - del(connection) - del(db) - # TODO: Drop and recreate indexes # setup app and return -- 2.25.1