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 <Sebastian@SSpaeth.de>
This commit is contained in:
parent
a5cf95c5ad
commit
40cec2b444
@ -44,7 +44,7 @@ BIG_BLUE = resource('bigblue.png')
|
|||||||
|
|
||||||
class TestAPI(object):
|
class TestAPI(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.app = get_test_app()
|
self.app = get_test_app(dump_old_app=False)
|
||||||
self.db = mg_globals.database
|
self.db = mg_globals.database
|
||||||
|
|
||||||
self.user_password = u'4cc355_70k3N'
|
self.user_password = u'4cc355_70k3N'
|
||||||
|
@ -27,7 +27,7 @@ from mediagoblin.tests import test_oauth as oauth
|
|||||||
|
|
||||||
class TestHTTPCallback(object):
|
class TestHTTPCallback(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.app = get_test_app()
|
self.app = get_test_app(dump_old_app=False)
|
||||||
self.db = mg_globals.database
|
self.db = mg_globals.database
|
||||||
|
|
||||||
self.user_password = u'secret'
|
self.user_password = u'secret'
|
||||||
|
@ -50,7 +50,7 @@ REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request']
|
|||||||
|
|
||||||
class TestSubmission:
|
class TestSubmission:
|
||||||
def setUp(self):
|
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:
|
# TODO: Possibly abstract into a decorator like:
|
||||||
# @as_authenticated_user('chris')
|
# @as_authenticated_user('chris')
|
||||||
@ -132,11 +132,11 @@ class TestSubmission:
|
|||||||
def test_tags(self):
|
def test_tags(self):
|
||||||
# Good tag string
|
# 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},
|
'tags': GOOD_TAG_STRING},
|
||||||
*REQUEST_CONTEXT, do_follow=True,
|
*REQUEST_CONTEXT, do_follow=True,
|
||||||
**self.upload_data(GOOD_JPG))
|
**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]['name'] == u'yin'
|
||||||
assert media.tags[0]['slug'] == u'yin'
|
assert media.tags[0]['slug'] == u'yin'
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class TestSubmission:
|
|||||||
|
|
||||||
# Test tags that are too long
|
# 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},
|
'tags': BAD_TAG_STRING},
|
||||||
*FORM_CONTEXT,
|
*FORM_CONTEXT,
|
||||||
**self.upload_data(GOOD_JPG))
|
**self.upload_data(GOOD_JPG))
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from mediagoblin import mg_globals
|
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
|
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 :)
|
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
|
assert User.query.count() == 0
|
||||||
|
|
||||||
new_user = mg_globals.database.User()
|
fixture_add_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()
|
|
||||||
assert User.query.count() == 1
|
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
|
assert User.query.count() == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user