@@ 499-527 (lines=29) @@ | ||
496 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
497 | ) |
|
498 | ||
499 | def test_activation_with_expired_fail(self): |
|
500 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
501 | send_email=False, |
|
502 | **self.user_info) |
|
503 | ||
504 | profile = new_user.registration_profile |
|
505 | RegistrationProfile.objects.accept_registration( |
|
506 | profile, site=self.mock_site |
|
507 | ) |
|
508 | ||
509 | new_user.date_joined -= datetime.timedelta( |
|
510 | days=settings.ACCOUNT_ACTIVATION_DAYS + 1 |
|
511 | ) |
|
512 | new_user.save() |
|
513 | ||
514 | result = RegistrationProfile.objects.activate_user( |
|
515 | activation_key=profile.activation_key, |
|
516 | site=self.mock_site, |
|
517 | password='swordfish' |
|
518 | ) |
|
519 | ||
520 | self.failIf(result) |
|
521 | # the user should not be activated |
|
522 | self.failIf(new_user.is_active) |
|
523 | self.failIf(new_user.has_usable_password()) |
|
524 | self.failIf(new_user.check_password('swordfish')) |
|
525 | # inspection profile should not be deleted |
|
526 | self.failUnless( |
|
527 | RegistrationProfile.objects.filter(pk=profile.pk).exists() |
|
528 | ) |
|
529 | ||
530 | def test_activation_with_invalid_key_fail(self): |
|
@@ 387-415 (lines=29) @@ | ||
384 | # inspection profile should be deleted |
|
385 | self.failIf(RegistrationProfile.objects.filter(pk=profile.pk).exists()) |
|
386 | ||
387 | def test_activation_without_password(self): |
|
388 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
389 | send_email=False, |
|
390 | **self.user_info) |
|
391 | ||
392 | profile = new_user.registration_profile |
|
393 | RegistrationProfile.objects.accept_registration( |
|
394 | profile, site=self.mock_site, send_email=False |
|
395 | ) |
|
396 | activated = RegistrationProfile.objects.activate_user( |
|
397 | activation_key=profile.activation_key, |
|
398 | site=self.mock_site, |
|
399 | send_email=False |
|
400 | ) |
|
401 | ||
402 | self.failUnless(activated) |
|
403 | ||
404 | activated_user, password, is_generated = activated |
|
405 | ||
406 | self.assertEqual(new_user, activated_user) |
|
407 | self.assertEqual(len(password), |
|
408 | settings.REGISTRATION_DEFAULT_PASSWORD_LENGTH) |
|
409 | self.assertEqual(is_generated, True) |
|
410 | # the user should be activated with the password |
|
411 | self.failUnless(activated_user.is_active) |
|
412 | self.failUnless(activated_user.has_usable_password()) |
|
413 | self.failUnless(activated_user.check_password(password)) |
|
414 | # inspection profile should be deleted |
|
415 | self.failIf(RegistrationProfile.objects.filter(pk=profile.pk).exists()) |
|
416 | ||
417 | def test_activation_email(self): |
|
418 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |
|
@@ 358-385 (lines=28) @@ | ||
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, |
|
360 | send_email=False, |
|
361 | **self.user_info) |
|
362 | ||
363 | profile = new_user.registration_profile |
|
364 | RegistrationProfile.objects.accept_registration( |
|
365 | profile, site=self.mock_site, send_email=False |
|
366 | ) |
|
367 | activated = RegistrationProfile.objects.activate_user( |
|
368 | activation_key=profile.activation_key, |
|
369 | site=self.mock_site, |
|
370 | password='swordfish', |
|
371 | send_email=False) |
|
372 | ||
373 | self.failUnless(activated) |
|
374 | ||
375 | activated_user, password, is_generated = activated |
|
376 | ||
377 | self.assertEqual(new_user, activated_user) |
|
378 | self.assertEqual(password, 'swordfish') |
|
379 | self.assertEqual(is_generated, False) |
|
380 | # the user should be activated with the password |
|
381 | self.failUnless(activated_user.is_active) |
|
382 | self.failUnless(activated_user.has_usable_password()) |
|
383 | self.failUnless(activated_user.check_password(password)) |
|
384 | # inspection profile should be deleted |
|
385 | self.failIf(RegistrationProfile.objects.filter(pk=profile.pk).exists()) |
|
386 | ||
387 | def test_activation_without_password(self): |
|
388 | new_user = RegistrationProfile.objects.register(site=self.mock_site, |