+ # Failed login - blank form
+ # -------------------------
+ util.clear_test_template_context()
+ response = test_app.post('/auth/login/')
+ context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
+ form = context['login_form']
+ assert form.username.errors == [u'This field is required.']
+ assert form.password.errors == [u'This field is required.']
+
+ # Failed login - blank user
+ # -------------------------
+ util.clear_test_template_context()
+ response = test_app.post(
+ '/auth/login/', {
+ 'password': u'toast'})
+ context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
+ form = context['login_form']
+ assert form.username.errors == [u'This field is required.']
+
+ # Failed login - blank password
+ # -----------------------------
+ util.clear_test_template_context()
+ response = test_app.post(
+ '/auth/login/', {
+ 'username': u'chris'})
+ context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
+ form = context['login_form']
+ assert form.password.errors == [u'This field is required.']
+
+ # Failed login - bad user
+ # -----------------------
+ util.clear_test_template_context()
+ response = test_app.post(
+ '/auth/login/', {
+ 'username': u'steve',
+ 'password': 'toast'})
+ context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
+ assert context['login_failed']
+
+ # Failed login - bad password
+ # ---------------------------
+ util.clear_test_template_context()
+ response = test_app.post(
+ '/auth/login/', {
+ 'username': u'chris',
+ 'password': 'jam'})
+ context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
+ assert context['login_failed']
+
+ # Successful login
+ # ----------------