@@ 530-553 (lines=24) @@ | ||
527 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
528 | ) |
|
529 | ||
530 | def test_activation_with_invalid_key_fail(self): |
|
531 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
532 | send_email=False, |
|
533 | **self.user_info) |
|
534 | ||
535 | profile = new_user.registration_profile |
|
536 | RegistrationProfile.objects.accept_registration( |
|
537 | profile, site=self.mock_site |
|
538 | ) |
|
539 | ||
540 | result = RegistrationProfile.objects.activate_user( |
|
541 | activation_key='foo', |
|
542 | site=self.mock_site, |
|
543 | password='swordfish' |
|
544 | ) |
|
545 | ||
546 | self.failIf(result) |
|
547 | # the user should not be activated |
|
548 | self.failIf(new_user.is_active) |
|
549 | self.failIf(new_user.has_usable_password()) |
|
550 | self.failIf(new_user.check_password('swordfish')) |
|
551 | # inspection profile should not be deleted |
|
552 | self.failUnless( |
|
553 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
554 | ) |
|
555 | ||
556 | def test_expired_user_deletion(self): |
|
@@ 473-496 (lines=24) @@ | ||
470 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
471 | ) |
|
472 | ||
473 | def test_activation_with_rejected_fail(self): |
|
474 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
475 | send_email=False, |
|
476 | **self.user_info) |
|
477 | ||
478 | profile = new_user.registration_profile |
|
479 | RegistrationProfile.objects.reject_registration( |
|
480 | profile, site=self.mock_site |
|
481 | ) |
|
482 | ||
483 | result = RegistrationProfile.objects.activate_user( |
|
484 | activation_key=profile.activation_key, |
|
485 | site=self.mock_site, |
|
486 | password='swordfish' |
|
487 | ) |
|
488 | ||
489 | self.failIf(result) |
|
490 | # the user should not be activated |
|
491 | self.failIf(new_user.is_active) |
|
492 | self.failIf(new_user.has_usable_password()) |
|
493 | self.failIf(new_user.check_password('swordfish')) |
|
494 | # inspection profile should not be deleted |
|
495 | self.failUnless( |
|
496 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
497 | ) |
|
498 | ||
499 | def test_activation_with_expired_fail(self): |
|
@@ 335-356 (lines=22) @@ | ||
332 | self.assertEqual(profile.status, 'accepted') |
|
333 | self.assertNotEqual(profile.activation_key, None) |
|
334 | ||
335 | def test_rejection_after_rejection_fail(self): |
|
336 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
337 | send_email=False, |
|
338 | **self.user_info) |
|
339 | ||
340 | profile = new_user.registration_profile |
|
341 | ||
342 | # accept |
|
343 | result = RegistrationProfile.objects.reject_registration( |
|
344 | profile, site=self.mock_site |
|
345 | ) |
|
346 | self.failUnless(result) |
|
347 | self.assertEqual(profile.status, 'rejected') |
|
348 | self.assertEqual(profile.activation_key, None) |
|
349 | ||
350 | # reject should not work |
|
351 | result = RegistrationProfile.objects.reject_registration( |
|
352 | profile, site=self.mock_site |
|
353 | ) |
|
354 | self.failIf(result) |
|
355 | self.assertEqual(profile.status, 'rejected') |
|
356 | self.assertEqual(profile.activation_key, None) |
|
357 | ||
358 | def test_activation_with_password(self): |
|
359 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
@@ 289-310 (lines=22) @@ | ||
286 | self.assertEqual(profile.status, 'accepted') |
|
287 | self.assertNotEqual(profile.activation_key, None) |
|
288 | ||
289 | def test_acceptance_after_acceptance_fail(self): |
|
290 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
291 | send_email=False, |
|
292 | **self.user_info) |
|
293 | ||
294 | profile = new_user.registration_profile |
|
295 | ||
296 | # accept |
|
297 | result = RegistrationProfile.objects.accept_registration( |
|
298 | profile, site=self.mock_site |
|
299 | ) |
|
300 | self.failUnless(result) |
|
301 | self.assertEqual(profile.status, 'accepted') |
|
302 | self.assertNotEqual(profile.activation_key, None) |
|
303 | ||
304 | # accept should not work |
|
305 | result = RegistrationProfile.objects.accept_registration( |
|
306 | profile, site=self.mock_site |
|
307 | ) |
|
308 | self.failIf(result) |
|
309 | self.assertEqual(profile.status, 'accepted') |
|
310 | self.assertNotEqual(profile.activation_key, None) |
|
311 | ||
312 | def test_rejection_after_acceptance_fail(self): |
|
313 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
@@ 450-470 (lines=21) @@ | ||
447 | ||
448 | self.assertEqual(len(mail.outbox), 0) |
|
449 | ||
450 | def test_activation_with_untreated_fail(self): |
|
451 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
452 | send_email=False, |
|
453 | **self.user_info) |
|
454 | ||
455 | profile = new_user.registration_profile |
|
456 | ||
457 | result = RegistrationProfile.objects.activate_user( |
|
458 | activation_key=profile.activation_key, |
|
459 | site=self.mock_site, |
|
460 | password='swordfish' |
|
461 | ) |
|
462 | ||
463 | self.failIf(result) |
|
464 | # the user should not be activated |
|
465 | self.failIf(new_user.is_active) |
|
466 | self.failIf(new_user.has_usable_password()) |
|
467 | self.failIf(new_user.check_password('swordfish')) |
|
468 | # inspection profile should not be deleted |
|
469 | self.failUnless( |
|
470 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
471 | ) |
|
472 | ||
473 | def test_activation_with_rejected_fail(self): |