Make sure we *ONLY* ever kill the test database, EVER.

This commit is contained in:
Christopher Allan Webber 2011-06-21 16:04:44 -05:00
parent 4fd18da0a8
commit cfd2cbf3dd
2 changed files with 9 additions and 9 deletions

View File

@ -16,12 +16,15 @@
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.tests.tools import MEDIAGOBLIN_TEST_DB_NAME
def setup_package(): def setup_package():
pass pass
def teardown_package(): def teardown_package():
if mg_globals.db_connection: if ((mg_globals.db_connection
print "Killing db ..." and mg_globals.database.name == MEDIAGOBLIN_TEST_DB_NAME)):
mg_globals.db_connection.drop_database(mg_globals.database.name) print "Killing db ..."
print "... done" mg_globals.db_connection.drop_database(MEDIAGOBLIN_TEST_DB_NAME)
print "... done"

View File

@ -28,7 +28,7 @@ from mediagoblin.decorators import _make_safe
from mediagoblin.db.open import setup_connection_and_db_from_config 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( TEST_SERVER_CONFIG = pkg_resources.resource_filename(
'mediagoblin.tests', 'test_paste.ini') 'mediagoblin.tests', 'test_paste.ini')
TEST_APP_CONFIG = pkg_resources.resource_filename( 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 # @@: For now we're dropping collections, but we could also just
# collection.remove() ? # collection.remove() ?
connection, db = setup_connection_and_db_from_config(app_config) connection, db = setup_connection_and_db_from_config(app_config)
assert db.name == MEDIAGOBLIN_TEST_DB_NAME
collections_to_wipe = [ collections_to_wipe = [
collection collection
@ -87,10 +88,6 @@ def get_test_app(dump_old_app=True):
for collection in collections_to_wipe: for collection in collections_to_wipe:
db.drop_collection(collection) db.drop_collection(collection)
# Don't need these anymore...
del(connection)
del(db)
# TODO: Drop and recreate indexes # TODO: Drop and recreate indexes
# setup app and return # setup app and return