Rename get_test_app to get_app.

nosetests runs everything that even vaguely looks like a
test case... even our get_test_app. And as it is imported
everywhere... it is run everywhere as a test case. Renaming
it saves us about 10+ tests and a few seconds of time.
This commit is contained in:
Elrond 2013-01-18 11:40:40 +01:00
parent 4637d50cfc
commit 1be247b36e
12 changed files with 32 additions and 32 deletions

View File

@ -22,7 +22,7 @@ from pkg_resources import resource_filename
from mediagoblin import mg_globals
from mediagoblin.tools import template, pluginapi
from mediagoblin.tests.tools import get_test_app, fixture_add_user
from mediagoblin.tests.tools import get_app, fixture_add_user
_log = logging.getLogger(__name__)
@ -44,7 +44,7 @@ BIG_BLUE = resource('bigblue.png')
class TestAPI(object):
def setUp(self):
self.app = get_test_app(dump_old_app=False)
self.app = get_app(dump_old_app=False)
self.db = mg_globals.database
self.user_password = u'4cc355_70k3N'

View File

@ -22,7 +22,7 @@ from nose.tools import assert_equal
from mediagoblin import mg_globals
from mediagoblin.auth import lib as auth_lib
from mediagoblin.db.models import User
from mediagoblin.tests.tools import get_test_app, fixture_add_user
from mediagoblin.tests.tools import setup_fresh_app, get_app, fixture_add_user
from mediagoblin.tools import template, mail
@ -67,11 +67,11 @@ def test_bcrypt_gen_password_hash():
'notthepassword', hashed_pw, '3><7R45417')
def test_register_views():
@setup_fresh_app
def test_register_views(test_app):
"""
Massive test function that all our registration-related views all work.
"""
test_app = get_test_app(dump_old_app=False)
# Test doing a simple GET on the page
# -----------------------------------
@ -125,7 +125,7 @@ def test_register_views():
u'Invalid email address.']
## At this point there should be no users in the database ;)
assert not User.query.count()
assert_equal(User.query.count(), 0)
# Successful register
# -------------------
@ -315,7 +315,7 @@ def test_authentication_views():
"""
Test logging in and logging out
"""
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
# Make a new user
test_user = fixture_add_user(active_user=False)

View File

@ -14,12 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin.tests.tools import get_test_app
from mediagoblin.tests.tools import get_app
from mediagoblin import mg_globals
def test_csrf_cookie_set():
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
cookie_name = mg_globals.app_config['csrf_cookie_name']
# get login page
@ -37,7 +37,7 @@ def test_csrf_token_must_match():
# We need a fresh app for this test on webtest < 1.3.6.
# We do not understand why, but it fixes the tests.
# If we require webtest >= 1.3.6, we can switch to a non fresh app here.
test_app = get_test_app(dump_old_app=True)
test_app = get_app(dump_old_app=True)
# construct a request with no cookie or form token
assert test_app.post('/auth/login/',
@ -68,7 +68,7 @@ def test_csrf_token_must_match():
status_int == 200
def test_csrf_exempt():
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
# monkey with the views to decorate a known endpoint
import mediagoblin.auth.views
from mediagoblin.meddleware.csrf import csrf_exempt

View File

@ -18,13 +18,13 @@ from nose.tools import assert_equal
from mediagoblin import mg_globals
from mediagoblin.db.models import User
from mediagoblin.tests.tools import get_test_app, fixture_add_user
from mediagoblin.tests.tools import get_app, fixture_add_user
from mediagoblin.tools import template
from mediagoblin.auth.lib import bcrypt_check_password
class TestUserEdit(object):
def setUp(self):
self.app = get_test_app(dump_old_app=False)
self.app = get_app(dump_old_app=False)
# set up new user
self.user_password = u'toast'
self.user = fixture_add_user(password = self.user_password)

View File

@ -20,14 +20,14 @@ from urlparse import urlparse, parse_qs
from mediagoblin import mg_globals
from mediagoblin.tools import processing
from mediagoblin.tests.tools import get_test_app, fixture_add_user
from mediagoblin.tests.tools import get_app, fixture_add_user
from mediagoblin.tests.test_submission import GOOD_PNG
from mediagoblin.tests import test_oauth as oauth
class TestHTTPCallback(object):
def setUp(self):
self.app = get_test_app(dump_old_app=False)
self.app = get_app(dump_old_app=False)
self.db = mg_globals.database
self.user_password = u'secret'

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin.messages import fetch_messages, add_message
from mediagoblin.tests.tools import get_test_app
from mediagoblin.tests.tools import get_app
from mediagoblin.tools import template
@ -26,7 +26,7 @@ def test_messages():
fetched messages should be the same as the added ones,
and fetching should clear the message list.
"""
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
# Aquire a request object
test_app.get('/')
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']

View File

@ -16,9 +16,9 @@
from nose.tools import assert_equal
from mediagoblin.tests.tools import get_test_app
from mediagoblin.tests.tools import get_app
def test_404_for_non_existent():
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
res = test_app.get('/does-not-exist/', expect_errors=True)
assert_equal(res.status_int, 404)

View File

@ -21,7 +21,7 @@ from urlparse import parse_qs, urlparse
from mediagoblin import mg_globals
from mediagoblin.tools import template, pluginapi
from mediagoblin.tests.tools import get_test_app, fixture_add_user
from mediagoblin.tests.tools import get_app, fixture_add_user
_log = logging.getLogger(__name__)
@ -29,7 +29,7 @@ _log = logging.getLogger(__name__)
class TestOAuth(object):
def setUp(self):
self.app = get_test_app()
self.app = get_app()
self.db = mg_globals.database
self.pman = pluginapi.PluginManager()

View File

@ -24,7 +24,7 @@ import os
from nose.tools import assert_equal, assert_true
from pkg_resources import resource_filename
from mediagoblin.tests.tools import get_test_app, \
from mediagoblin.tests.tools import get_app, \
fixture_add_user
from mediagoblin import mg_globals
from mediagoblin.tools import template
@ -50,7 +50,7 @@ REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request']
class TestSubmission:
def setUp(self):
self.test_app = get_test_app(dump_old_app=False)
self.test_app = get_app(dump_old_app=False)
# TODO: Possibly abstract into a decorator like:
# @as_authenticated_user('chris')

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin.tests.tools import get_test_app
from mediagoblin.tests.tools import get_app
from mediagoblin.tools import text
def test_list_of_dicts_conversion():
@ -24,7 +24,7 @@ def test_list_of_dicts_conversion():
as a dict. Each tag dict should contain the tag's name and slug. Another
function performs the reverse operation when populating a form to edit tags.
"""
test_app = get_test_app(dump_old_app=False)
test_app = get_app(dump_old_app=False)
# Leading, trailing, and internal whitespace should be removed and slugified
assert text.convert_to_tag_list_of_dicts('sleep , 6 AM, chainsaw! ') == [
{'name': u'sleep', 'slug': u'sleep'},

View File

@ -15,22 +15,22 @@
# 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, fixture_add_user
from mediagoblin.tests.tools import get_app, fixture_add_user
from mediagoblin.db.models import User
def test_get_test_app_wipes_db():
def test_get_app_wipes_db():
"""
Make sure we get a fresh database on every wipe :)
"""
get_test_app(dump_old_app=True)
get_app(dump_old_app=True)
assert User.query.count() == 0
fixture_add_user()
assert User.query.count() == 1
get_test_app(dump_old_app=False)
get_app(dump_old_app=False)
assert User.query.count() == 1
get_test_app(dump_old_app=True)
get_app(dump_old_app=True)
assert User.query.count() == 0

View File

@ -103,7 +103,7 @@ def suicide_if_bad_celery_environ():
raise BadCeleryEnviron(BAD_CELERY_MESSAGE)
def get_test_app(dump_old_app=True):
def get_app(dump_old_app=True):
suicide_if_bad_celery_environ()
# Make sure we've turned on testing
@ -164,7 +164,7 @@ def setup_fresh_app(func):
"""
@wraps(func)
def wrapper(*args, **kwargs):
test_app = get_test_app()
test_app = get_app()
testing.clear_test_buckets()
return func(test_app, *args, **kwargs)