Don't get a fresh app when not needed
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Tue, 8 Jan 2013 10:57:25 +0000 (11:57 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Tue, 8 Jan 2013 10:57:25 +0000 (11:57 +0100)
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 <Sebastian@SSpaeth.de>
mediagoblin/tests/test_api.py
mediagoblin/tests/test_http_callback.py
mediagoblin/tests/test_submission.py
mediagoblin/tests/test_tests.py

index 188cdadb4e269b310d18c0eeb248c54d51fbab15..4b784da36422a731c7a85b82d51ccaf0a22069be 100644 (file)
@@ -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'
index 8b0a03b973e612d23a07e0a429458abb1195a7e8..0f6e489f396ab96b1b291dca6e2e2b34441e0802 100644 (file)
@@ -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'
index 589ba7ed6f0bb181868934b7041c80bc0b1650f3..faf4e744967c50f30c51bb3ae8192c64fac43b9c 100644 (file)
@@ -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))
index b11dc730df7c6b108f9a59480e266fe6090a5896..d09e8f284bc21774427c727a9a69b810d02f09ce 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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