From 460ce56493442b1d89270313e7789fd455ef71e6 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 5 Jun 2011 10:34:29 -0500 Subject: [PATCH] The first bit of the registration tests working. Not fully there, but it's clear that the webtest part is working, without having tested the database yet. :) --- mediagoblin/tests/test_auth.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index 94ce6bba..b0355732 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -17,6 +17,10 @@ from mediagoblin.auth import lib as auth_lib +from mediagoblin.tests.tools import get_test_app + +from mediagoblin import util + ######################## # Test bcrypt auth funcs @@ -57,3 +61,25 @@ def test_bcrypt_gen_password_hash(): pw, hashed_pw, '3><7R45417') assert not auth_lib.bcrypt_check_password( 'notthepassword', hashed_pw, '3><7R45417') + + +def test_register_views(): + util.clear_test_template_context() + test_app = get_test_app() + + # Test doing a simple GET on the page + test_app.get('/auth/register/') + # Make sure it rendered with the appropriate template + assert util.TEMPLATE_TEST_CONTEXT.has_key( + 'mediagoblin/auth/register.html') + + # Try to register without providing anything, should error + util.clear_test_template_context() + test_app.post( + '/auth/register/', {}) + context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html'] + form = context['register_form'] + assert form.username.errors == [u'This field is required.'] + assert form.password.errors == [u'This field is required.'] + assert form.confirm_password.errors == [u'This field is required.'] + assert form.email.errors == [u'This field is required.'] -- 2.25.1