@@ 123-139 (lines=17) @@ | ||
120 | ||
121 | settings.REGISTRATION_OPEN = True |
|
122 | ||
123 | def test_activation_view_get_success(self): |
|
124 | """ |
|
125 | A ``GET`` to the ``ActivationView`` view with valid activation_key |
|
126 | ||
127 | """ |
|
128 | new_user = self.backend.register(username='alice', email='[email protected]', request=self.mock_request) |
|
129 | new_user = self.backend.accept(new_user.registration_profile, request=self.mock_request) |
|
130 | ||
131 | activation_url = reverse('registration_activate', kwargs={ |
|
132 | 'activation_key': new_user.registration_profile.activation_key}) |
|
133 | ||
134 | response = self.client.get(activation_url) |
|
135 | self.assertEqual(response.status_code, 200) |
|
136 | self.assertTemplateUsed(response, |
|
137 | 'registration/activation_form.html') |
|
138 | self.failUnless(isinstance(response.context['form'], |
|
139 | forms.ActivationForm)) |
|
140 | ||
141 | def test_activation_view_get_fail(self): |
|
142 | """ |
@@ 94-110 (lines=17) @@ | ||
91 | self.assertEqual(profile.status, 'rejected') |
|
92 | self.assertEqual(profile.activation_key, None) |
|
93 | ||
94 | def test_activation_with_password(self): |
|
95 | new_user = self.backend.register( |
|
96 | username='bob', email='[email protected]', |
|
97 | request=self.mock_request) |
|
98 | ||
99 | profile = new_user.registration_profile |
|
100 | self.backend.accept(profile, request=self.mock_request) |
|
101 | activated_user = self.backend.activate( |
|
102 | activation_key=profile.activation_key, |
|
103 | request=self.mock_request, |
|
104 | password='swardfish') |
|
105 | ||
106 | self.failUnless(activated_user) |
|
107 | self.assertEqual(activated_user, new_user) |
|
108 | self.failUnless(activated_user.is_active) |
|
109 | self.failUnless(activated_user.has_usable_password()) |
|
110 | self.failUnless(activated_user.check_password('swardfish')) |
|
111 | ||
112 | def test_activation_without_password(self): |
|
113 | new_user = self.backend.register( |
|
@@ 112-126 (lines=15) @@ | ||
109 | self.failUnless(activated_user.has_usable_password()) |
|
110 | self.failUnless(activated_user.check_password('swardfish')) |
|
111 | ||
112 | def test_activation_without_password(self): |
|
113 | new_user = self.backend.register( |
|
114 | username='bob', email='[email protected]', |
|
115 | request=self.mock_request) |
|
116 | ||
117 | profile = new_user.registration_profile |
|
118 | self.backend.accept(profile, request=self.mock_request) |
|
119 | activated_user = self.backend.activate( |
|
120 | activation_key=profile.activation_key, |
|
121 | request=self.mock_request) |
|
122 | ||
123 | self.failUnless(activated_user) |
|
124 | self.assertEqual(activated_user, new_user) |
|
125 | self.failUnless(activated_user.is_active) |
|
126 | self.failUnless(activated_user.has_usable_password()) |
|
127 | ||
128 | def test_untreated_activation(self): |
|
129 | User = get_user_model() |