From: Sebastian Spaeth Date: Tue, 8 Jan 2013 10:57:25 +0000 (+0100) Subject: Don't get a fresh app when not needed X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=40cec2b4445cc3ff0aabddcf1ecae26756d5759f;p=mediagoblin.git Don't get a fresh app when not needed These tests, don't need fresh databases, so don't discard and recreate the tables. This reduces test suite runtime on my laptop from 130 to 96 seconds. Signed-off-by: Sebastian Spaeth --- diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py index 188cdadb..4b784da3 100644 --- a/mediagoblin/tests/test_api.py +++ b/mediagoblin/tests/test_api.py @@ -44,7 +44,7 @@ BIG_BLUE = resource('bigblue.png') class TestAPI(object): def setUp(self): - self.app = get_test_app() + self.app = get_test_app(dump_old_app=False) self.db = mg_globals.database self.user_password = u'4cc355_70k3N' diff --git a/mediagoblin/tests/test_http_callback.py b/mediagoblin/tests/test_http_callback.py index 8b0a03b9..0f6e489f 100644 --- a/mediagoblin/tests/test_http_callback.py +++ b/mediagoblin/tests/test_http_callback.py @@ -27,7 +27,7 @@ from mediagoblin.tests import test_oauth as oauth class TestHTTPCallback(object): def setUp(self): - self.app = get_test_app() + self.app = get_test_app(dump_old_app=False) self.db = mg_globals.database self.user_password = u'secret' diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py index 589ba7ed..faf4e744 100644 --- a/mediagoblin/tests/test_submission.py +++ b/mediagoblin/tests/test_submission.py @@ -50,7 +50,7 @@ REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request'] class TestSubmission: def setUp(self): - self.test_app = get_test_app() + self.test_app = get_test_app(dump_old_app=False) # TODO: Possibly abstract into a decorator like: # @as_authenticated_user('chris') @@ -132,11 +132,11 @@ class TestSubmission: def test_tags(self): # Good tag string # -------- - response, request = self.do_post({'title': u'Balanced Goblin', + response, request = self.do_post({'title': u'Balanced Goblin 2', 'tags': GOOD_TAG_STRING}, *REQUEST_CONTEXT, do_follow=True, **self.upload_data(GOOD_JPG)) - media = self.check_media(request, {'title': u'Balanced Goblin'}, 1) + media = self.check_media(request, {'title': u'Balanced Goblin 2'}, 1) assert media.tags[0]['name'] == u'yin' assert media.tags[0]['slug'] == u'yin' @@ -145,7 +145,7 @@ class TestSubmission: # Test tags that are too long # --------------- - response, form = self.do_post({'title': u'Balanced Goblin', + response, form = self.do_post({'title': u'Balanced Goblin 2', 'tags': BAD_TAG_STRING}, *FORM_CONTEXT, **self.upload_data(GOOD_JPG)) diff --git a/mediagoblin/tests/test_tests.py b/mediagoblin/tests/test_tests.py index b11dc730..d09e8f28 100644 --- a/mediagoblin/tests/test_tests.py +++ b/mediagoblin/tests/test_tests.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from mediagoblin import mg_globals -from mediagoblin.tests.tools import get_test_app +from mediagoblin.tests.tools import get_test_app, fixture_add_user from mediagoblin.db.models import User @@ -23,16 +23,14 @@ def test_get_test_app_wipes_db(): """ Make sure we get a fresh database on every wipe :) """ - get_test_app() + get_test_app(dump_old_app=True) assert User.query.count() == 0 - new_user = mg_globals.database.User() - new_user.username = u'lolcat' - new_user.email = u'lol@cats.example.org' - new_user.pw_hash = u'pretend_this_is_a_hash' - new_user.save() + fixture_add_user() assert User.query.count() == 1 - get_test_app() + get_test_app(dump_old_app=False) + assert User.query.count() == 1 + get_test_app(dump_old_app=True) assert User.query.count() == 0