aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/tools.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2012-03-26 11:14:11 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2012-03-26 11:14:11 -0500
commitd693f6bd867871ba084f0da0ff8ba5a667174fc7 (patch)
tree5c892815706d250e02ee1b8986671fb01d836d94 /mediagoblin/tests/tools.py
parent7ccf41818581743c2e16935cd7308ad3d6694149 (diff)
downloadmediagoblin-d693f6bd867871ba084f0da0ff8ba5a667174fc7.tar.lz
mediagoblin-d693f6bd867871ba084f0da0ff8ba5a667174fc7.tar.xz
mediagoblin-d693f6bd867871ba084f0da0ff8ba5a667174fc7.zip
SQL based tests and refactored Celery setup stuff
- Changed config files of test configs to use SQL - Updated celery initialization tools, factored them to be able to use the "big instance" application stuff
Diffstat (limited to 'mediagoblin/tests/tools.py')
-rw-r--r--mediagoblin/tests/tools.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py
index 7cf355b0..a99173e8 100644
--- a/mediagoblin/tests/tools.py
+++ b/mediagoblin/tests/tools.py
@@ -26,8 +26,11 @@ from mediagoblin.tools import testing
from mediagoblin.init.config import read_mediagoblin_config
from mediagoblin.decorators import _make_safe
from mediagoblin.db.open import setup_connection_and_db_from_config
+from mediagoblin.db.sql.base import Session
from mediagoblin.meddleware import BaseMeddleware
from mediagoblin.auth.lib import bcrypt_gen_password_hash
+from mediagoblin.gmg_commands.dbupdate import run_dbupdate
+from mediagoblin.init.celery import setup_celery_app
MEDIAGOBLIN_TEST_DB_NAME = u'__mediagoblin_tests__'
@@ -125,26 +128,19 @@ def get_test_app(dump_old_app=True):
global_config, validation_result = read_mediagoblin_config(TEST_APP_CONFIG)
app_config = global_config['mediagoblin']
- # Wipe database
- # @@: 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
- for collection in db.collection_names()
- if not collection.startswith('system.')]
-
- for collection in collections_to_wipe:
- db.drop_collection(collection)
-
- # TODO: Drop and recreate indexes
+ # Run database setup/migrations
+ run_dbupdate(app_config)
# setup app and return
test_app = loadapp(
'config:' + TEST_SERVER_CONFIG)
+ Session.rollback()
+ Session.remove()
+
+ # Re-setup celery
+ setup_celery_app(app_config, global_config)
+
# Insert the TestingMeddleware, which can do some
# sanity checks on every request/response.
# Doing it this way is probably not the cleanest way.