@@ 348-369 (lines=22) @@ | ||
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( |
|
350 | username='bob', email='[email protected]', |
|
351 | request=self.mock_request) |
|
352 | self.backend.reject( |
|
353 | new_user.registration_profile, |
|
354 | request=self.mock_request) |
|
355 | ||
356 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
357 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
358 | response = self.client.post(url, { |
|
359 | '_supplement-TOTAL_FORMS': 0, |
|
360 | '_supplement-INITIAL_FORMS': 0, |
|
361 | '_supplement-MAXNUM_FORMS': '', |
|
362 | 'action_name': 'force_activate' |
|
363 | }) |
|
364 | ||
365 | self.assertEqual(response.status_code, 302) |
|
366 | self.assertRedirects(response, redirect_url) |
|
367 | ||
368 | profile = RegistrationProfile.objects.filter(user__pk=new_user.pk) |
|
369 | self.failIf(profile.exists()) |
|
370 | ||
371 | def test_resend_acceptance_email_action(self): |
|
372 | admin_class = RegistrationAdmin(RegistrationProfile, admin.site) |
|
@@ 245-266 (lines=22) @@ | ||
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( |
|
247 | username='bob', email='[email protected]', |
|
248 | request=self.mock_request) |
|
249 | self.backend.accept( |
|
250 | new_user.registration_profile, |
|
251 | request=self.mock_request) |
|
252 | ||
253 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
254 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
255 | response = self.client.post(url, { |
|
256 | '_supplement-TOTAL_FORMS': 0, |
|
257 | '_supplement-INITIAL_FORMS': 0, |
|
258 | '_supplement-MAXNUM_FORMS': '', |
|
259 | 'action_name': 'activate' |
|
260 | }) |
|
261 | ||
262 | self.assertEqual(response.status_code, 302) |
|
263 | self.assertRedirects(response, redirect_url) |
|
264 | ||
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( |
|
@@ 115-136 (lines=22) @@ | ||
112 | self.assertEqual(profile.status, 'accepted') |
|
113 | self.assertNotEqual(profile.activation_key, previous_activation_key) |
|
114 | ||
115 | def test_change_view_post_valid_accept_from_rejected(self): |
|
116 | new_user = self.backend.register( |
|
117 | username='bob', email='[email protected]', |
|
118 | request=self.mock_request) |
|
119 | self.backend.reject( |
|
120 | new_user.registration_profile, |
|
121 | request=self.mock_request) |
|
122 | ||
123 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
124 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
125 | response = self.client.post(url, { |
|
126 | '_supplement-TOTAL_FORMS': 0, |
|
127 | '_supplement-INITIAL_FORMS': 0, |
|
128 | '_supplement-MAXNUM_FORMS': '', |
|
129 | 'action_name': 'accept' |
|
130 | }) |
|
131 | ||
132 | self.assertEqual(response.status_code, 302) |
|
133 | self.assertRedirects(response, redirect_url) |
|
134 | ||
135 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
136 | self.assertEqual(profile.status, 'accepted') |
|
137 | ||
138 | def test_change_view_post_valid_reject_from_untreated(self): |
|
139 | new_user = self.backend.register( |
|
@@ 298-316 (lines=19) @@ | ||
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( |
|
300 | username='bob', email='[email protected]', |
|
301 | request=self.mock_request) |
|
302 | ||
303 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
304 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
305 | response = self.client.post(url, { |
|
306 | '_supplement-TOTAL_FORMS': 0, |
|
307 | '_supplement-INITIAL_FORMS': 0, |
|
308 | '_supplement-MAXNUM_FORMS': '', |
|
309 | 'action_name': 'force_activate' |
|
310 | }) |
|
311 | ||
312 | self.assertEqual(response.status_code, 302) |
|
313 | self.assertRedirects(response, redirect_url) |
|
314 | ||
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( |
|
@@ 138-156 (lines=19) @@ | ||
135 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
136 | self.assertEqual(profile.status, 'accepted') |
|
137 | ||
138 | def test_change_view_post_valid_reject_from_untreated(self): |
|
139 | new_user = self.backend.register( |
|
140 | username='bob', email='[email protected]', |
|
141 | request=self.mock_request) |
|
142 | ||
143 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
144 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
145 | response = self.client.post(url, { |
|
146 | '_supplement-TOTAL_FORMS': 0, |
|
147 | '_supplement-INITIAL_FORMS': 0, |
|
148 | '_supplement-MAXNUM_FORMS': '', |
|
149 | 'action_name': 'reject' |
|
150 | }) |
|
151 | ||
152 | self.assertEqual(response.status_code, 302) |
|
153 | self.assertRedirects(response, redirect_url) |
|
154 | ||
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( |
|
@@ 71-89 (lines=19) @@ | ||
68 | ||
69 | self.assertEqual(response.status_code, 404) |
|
70 | ||
71 | def test_change_view_post_valid_accept_from_untreated(self): |
|
72 | new_user = self.backend.register( |
|
73 | username='bob', email='[email protected]', |
|
74 | request=self.mock_request) |
|
75 | ||
76 | url = urlresolvers.reverse('admin:registration_registrationprofile_change', args=(1,)) |
|
77 | redirect_url = urlresolvers.reverse('admin:registration_registrationprofile_changelist') |
|
78 | response = self.client.post(url, { |
|
79 | '_supplement-TOTAL_FORMS': 0, |
|
80 | '_supplement-INITIAL_FORMS': 0, |
|
81 | '_supplement-MAXNUM_FORMS': '', |
|
82 | 'action_name': 'accept' |
|
83 | }) |
|
84 | ||
85 | self.assertEqual(response.status_code, 302) |
|
86 | self.assertRedirects(response, redirect_url) |
|
87 | ||
88 | profile = RegistrationProfile.objects.get(user__pk=new_user.pk) |
|
89 | self.assertEqual(profile.status, 'accepted') |
|
90 | ||
91 | def test_change_view_post_valid_accept_from_accepted(self): |
|
92 | new_user = self.backend.register( |