@@ 85-101 (lines=17) @@ | ||
82 | profile = RegistrationProfile.objects.get(user__username='alice') |
|
83 | self.assertEqual(profile.supplement.remarks, 'Hello') |
|
84 | ||
85 | def test_registration_view_post_failure(self): |
|
86 | """ |
|
87 | A ``POST`` to the ``register`` view with invalid data does not |
|
88 | create a user, and displays appropriate error messages. |
|
89 | ||
90 | """ |
|
91 | response = self.client.post(reverse('registration_register'), |
|
92 | data={'username': 'bob', |
|
93 | 'email1': '[email protected]', |
|
94 | 'email2': '[email protected]', |
|
95 | 'remarks': 'Hello'}) |
|
96 | self.assertEqual(response.status_code, 200) |
|
97 | self.failIf(response.context['form'].is_valid()) |
|
98 | self.failUnless(response.context['supplement_form'].is_valid()) |
|
99 | self.assertFormError(response, 'form', field=None, |
|
100 | errors="The two email fields didn't match.") |
|
101 | self.assertEqual(len(mail.outbox), 0) |
|
102 | ||
103 | def test_registration_view_post_no_remarks_failure(self): |
|
104 | """ |
|
@@ 103-118 (lines=16) @@ | ||
100 | errors="The two email fields didn't match.") |
|
101 | self.assertEqual(len(mail.outbox), 0) |
|
102 | ||
103 | def test_registration_view_post_no_remarks_failure(self): |
|
104 | """ |
|
105 | A ``POST`` to the ``register`` view with invalid data does not |
|
106 | create a user, and displays appropriate error messages. |
|
107 | ||
108 | """ |
|
109 | response = self.client.post(reverse('registration_register'), |
|
110 | data={'username': 'bob', |
|
111 | 'email1': '[email protected]', |
|
112 | 'email2': '[email protected]'}) |
|
113 | self.assertEqual(response.status_code, 200) |
|
114 | self.failUnless(response.context['form'].is_valid()) |
|
115 | self.failIf(response.context['supplement_form'].is_valid()) |
|
116 | self.assertFormError(response, 'supplement_form', field='remarks', |
|
117 | errors="This field is required.") |
|
118 | self.assertEqual(len(mail.outbox), 0) |
|
119 |