diff options
Diffstat (limited to 'mediagoblin/tests/test_auth.py')
-rw-r--r-- | mediagoblin/tests/test_auth.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index a40c9cbc..f4409121 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -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 # ----------------------------------- @@ -105,10 +105,8 @@ def test_register_views(): context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html'] form = context['register_form'] - assert form.username.errors == [ - u'Field must be between 3 and 30 characters long.'] - assert form.password.errors == [ - u'Field must be between 6 and 30 characters long.'] + assert_equal (form.username.errors, [u'Field must be between 3 and 30 characters long.']) + assert_equal (form.password.errors, [u'Field must be between 5 and 1024 characters long.']) ## bad form template.clear_test_template_context() @@ -119,13 +117,11 @@ def test_register_views(): context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html'] form = context['register_form'] - assert form.username.errors == [ - u'Invalid input.'] - assert form.email.errors == [ - u'Invalid email address.'] + assert_equal (form.username.errors, [u'This field does not take email addresses.']) + assert_equal (form.email.errors, [u'This field requires an 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 +311,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) @@ -370,7 +366,7 @@ def test_authentication_views(): response = test_app.post( '/auth/login/', { 'username': u'chris', - 'password': 'jam'}) + 'password': 'jam_and_ham'}) context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html'] assert context['login_failed'] |