diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-04-01 15:36:11 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-04-01 15:36:11 -0500 |
commit | e089b66bde44ec90950a0acc9d471245295ffa4e (patch) | |
tree | 0c73c429ccbb312c5be22a17f4ee954f9461e75f /mediagoblin/tests/tools.py | |
parent | 1e3a0e0ca0c58ae740424fa6cf239f2dba5dc592 (diff) | |
parent | bc27a100fc05cea72c47d8ae446454d347d0a0ff (diff) | |
download | mediagoblin-e089b66bde44ec90950a0acc9d471245295ffa4e.tar.lz mediagoblin-e089b66bde44ec90950a0acc9d471245295ffa4e.tar.xz mediagoblin-e089b66bde44ec90950a0acc9d471245295ffa4e.zip |
Merge remote-tracking branch 'refs/remotes/elrond/sql/final'
Conflicts:
mediagoblin/tests/test_submission.py
Also, WHOO SQL SWITCHOVER PARTY!
ASCII DANCE PARTY
/_o_/ \ / \o_ o
( _|_ ) //)
/\ / o \ /| /|
*BMCH BMCH BMCH BMCH*
%
/_o_/ HHHYAAaaaaa
/_
/ /
%
AAAAAHAHAHAHAHHHAAHA
,, .------
o_o ;; /\\ \ $ __
'\/ || // \\ # /_/
\// // //\\ \
) \\ \ %
\\ \\_____\
| ) //-------
/_/_ // //
SWITCH YOUR DATABASE
FLIP A FUKKEN BOOLEAN
%
__________
.-' '-.
.' '.
.' _--_ _--_ '.
/ / (_). / (_). \
. | | | | .
| ._____, ._____, |
| ____________________ |
| | | |
' \ / '
\ '. .----./ /
\ '._ / / /
'. '--------' .'
'._ _.'
'----------'
Diffstat (limited to 'mediagoblin/tests/tools.py')
-rw-r--r-- | mediagoblin/tests/tools.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 7cf355b0..5b4e3746 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. @@ -216,4 +212,11 @@ def fixture_add_user(username = u'chris', password = 'toast', test_user.save() + # Reload + test_user = mg_globals.database.User.find_one({'username': username}) + + # ... and detach from session: + from mediagoblin.db.sql.base import Session + Session.expunge(test_user) + return test_user |