@@ 318-346 (lines=29) @@ | ||
315 | profile = RegistrationProfile.objects.filter(user__pk=new_user.pk) |
|
316 | self.failIf(profile.exists()) |
|
317 | ||
318 | def test_change_view_post_invalid_force_activate_from_accepted(self): |
|
319 | new_user = self.backend.register( |
|
320 | username='bob', email='[email protected]', |
|
321 | request=self.mock_request) |
|
322 | self.backend.accept( |
|
323 | new_user.registration_profile, |
|
324 | request=self.mock_request) |
|
325 | ||
326 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
327 | response = self.client.post(url, { |
|
328 | '_supplement-TOTAL_FORMS': 0, |
|
329 | '_supplement-INITIAL_FORMS': 0, |
|
330 | '_supplement-MAXNUM_FORMS': '', |
|
331 | 'action_name': 'force_activate' |
|
332 | }) |
|
333 | ||
334 | self.assertEqual(response.status_code, 200) |
|
335 | self.assertTemplateUsed( |
|
336 | response, |
|
337 | 'admin/registration/registrationprofile/change_form.html' |
|
338 | ) |
|
339 | self.failIf(response.context['adminform'].form.is_valid()) |
|
340 | self.assertEqual( |
|
341 | response.context['adminform'].form.errors['action_name'], |
|
342 | ["Select a valid choice. " |
|
343 | "force_activate is not one of the available choices."]) |
|
344 | ||
345 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
346 | self.assertEqual(profile.status, 'accepted') |
|
347 | ||
348 | def test_change_view_post_valid_force_activate_from_rejected(self): |
|
349 | new_user = self.backend.register( |
|
@@ 268-296 (lines=29) @@ | ||
265 | profile = RegistrationProfile.objects.filter(user__pk=new_user.pk) |
|
266 | self.failIf(profile.exists()) |
|
267 | ||
268 | def test_change_view_post_invalid_activate_from_rejected(self): |
|
269 | new_user = self.backend.register( |
|
270 | username='bob', email='[email protected]', |
|
271 | request=self.mock_request) |
|
272 | self.backend.reject( |
|
273 | new_user.registration_profile, |
|
274 | request=self.mock_request) |
|
275 | ||
276 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
277 | response = self.client.post(url, { |
|
278 | '_supplement-TOTAL_FORMS': 0, |
|
279 | '_supplement-INITIAL_FORMS': 0, |
|
280 | '_supplement-MAXNUM_FORMS': '', |
|
281 | 'action_name': 'activate' |
|
282 | }) |
|
283 | ||
284 | self.assertEqual(response.status_code, 200) |
|
285 | self.assertTemplateUsed( |
|
286 | response, |
|
287 | 'admin/registration/registrationprofile/change_form.html' |
|
288 | ) |
|
289 | self.failIf(response.context['adminform'].form.is_valid()) |
|
290 | self.assertEqual( |
|
291 | response.context['adminform'].form.errors['action_name'], |
|
292 | ["Select a valid choice. " |
|
293 | "activate is not one of the available choices."]) |
|
294 | ||
295 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
296 | self.assertEqual(profile.status, 'rejected') |
|
297 | ||
298 | def test_change_view_post_valid_force_activate_from_untreated(self): |
|
299 | new_user = self.backend.register( |
|
@@ 188-216 (lines=29) @@ | ||
185 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
186 | self.assertEqual(profile.status, 'accepted') |
|
187 | ||
188 | def test_change_view_post_invalid_reject_from_rejected(self): |
|
189 | new_user = self.backend.register( |
|
190 | username='bob', email='[email protected]', |
|
191 | request=self.mock_request) |
|
192 | self.backend.reject( |
|
193 | new_user.registration_profile, |
|
194 | request=self.mock_request) |
|
195 | ||
196 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
197 | response = self.client.post(url, { |
|
198 | '_supplement-TOTAL_FORMS': 0, |
|
199 | '_supplement-INITIAL_FORMS': 0, |
|
200 | '_supplement-MAXNUM_FORMS': '', |
|
201 | 'action_name': 'reject' |
|
202 | }) |
|
203 | ||
204 | self.assertEqual(response.status_code, 200) |
|
205 | self.assertTemplateUsed( |
|
206 | response, |
|
207 | 'admin/registration/registrationprofile/change_form.html' |
|
208 | ) |
|
209 | self.failIf(response.context['adminform'].form.is_valid()) |
|
210 | self.assertEqual( |
|
211 | response.context['adminform'].form.errors['action_name'], |
|
212 | ["Select a valid choice. " |
|
213 | "reject is not one of the available choices."]) |
|
214 | ||
215 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
216 | self.assertEqual(profile.status, 'rejected') |
|
217 | ||
218 | def test_change_view_post_invalid_activate_from_untreated(self): |
|
219 | new_user = self.backend.register( |
|
@@ 158-186 (lines=29) @@ | ||
155 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
156 | self.assertEqual(profile.status, 'rejected') |
|
157 | ||
158 | def test_change_view_post_invalid_reject_from_accepted(self): |
|
159 | new_user = self.backend.register( |
|
160 | username='bob', email='[email protected]', |
|
161 | request=self.mock_request) |
|
162 | self.backend.accept( |
|
163 | new_user.registration_profile, |
|
164 | request=self.mock_request) |
|
165 | ||
166 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
167 | response = self.client.post(url, { |
|
168 | '_supplement-TOTAL_FORMS': 0, |
|
169 | '_supplement-INITIAL_FORMS': 0, |
|
170 | '_supplement-MAXNUM_FORMS': '', |
|
171 | 'action_name': 'reject' |
|
172 | }) |
|
173 | ||
174 | self.assertEqual(response.status_code, 200) |
|
175 | self.assertTemplateUsed( |
|
176 | response, |
|
177 | 'admin/registration/registrationprofile/change_form.html' |
|
178 | ) |
|
179 | self.failIf(response.context['adminform'].form.is_valid()) |
|
180 | self.assertEqual( |
|
181 | response.context['adminform'].form.errors['action_name'], |
|
182 | ["Select a valid choice. " |
|
183 | "reject is not one of the available choices."]) |
|
184 | ||
185 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
186 | self.assertEqual(profile.status, 'accepted') |
|
187 | ||
188 | def test_change_view_post_invalid_reject_from_rejected(self): |
|
189 | new_user = self.backend.register( |
|
@@ 218-243 (lines=26) @@ | ||
215 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
216 | self.assertEqual(profile.status, 'rejected') |
|
217 | ||
218 | def test_change_view_post_invalid_activate_from_untreated(self): |
|
219 | new_user = self.backend.register( |
|
220 | username='bob', email='[email protected]', |
|
221 | request=self.mock_request) |
|
222 | ||
223 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
224 | response = self.client.post(url, { |
|
225 | '_supplement-TOTAL_FORMS': 0, |
|
226 | '_supplement-INITIAL_FORMS': 0, |
|
227 | '_supplement-MAXNUM_FORMS': '', |
|
228 | 'action_name': 'activate' |
|
229 | }) |
|
230 | ||
231 | self.assertEqual(response.status_code, 200) |
|
232 | self.assertTemplateUsed( |
|
233 | response, |
|
234 | 'admin/registration/registrationprofile/change_form.html' |
|
235 | ) |
|
236 | self.failIf(response.context['adminform'].form.is_valid()) |
|
237 | self.assertEqual( |
|
238 | response.context['adminform'].form.errors['action_name'], |
|
239 | ["Select a valid choice. " |
|
240 | "activate is not one of the available choices."]) |
|
241 | ||
242 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
243 | self.assertEqual(profile.status, 'untreated') |
|
244 | ||
245 | def test_change_view_post_valid_activate_from_accepted(self): |
|
246 | new_user = self.backend.register( |