def test_add_account_recovery(self): test_email = "*****@*****.**" pending_secondary_email_changes = PendingSecondaryEmailChange.objects.filter( user=self.user) assert 0 == len(pending_secondary_email_changes) account_recovery_objects = AccountRecovery.objects.filter( user=self.user) assert 0 == len(account_recovery_objects) with patch('crum.get_current_request', return_value=self.fake_request): update = {"secondary_email": test_email} update_account_settings(self.user, update) pending_secondary_email_change = PendingSecondaryEmailChange.objects.get( user=self.user) assert pending_secondary_email_change is not None assert pending_secondary_email_change.new_secondary_email == test_email activate_secondary_email(self.fake_request, pending_secondary_email_change.activation_key) pending_secondary_email_changes = PendingSecondaryEmailChange.objects.filter( user=self.user) assert 0 == len(pending_secondary_email_changes) account_recovery = AccountRecovery.objects.get(user=self.user) assert account_recovery is not None assert account_recovery.secondary_email == test_email
def test_add_account_recovery(self): test_email = "*****@*****.**" pending_secondary_email_changes = PendingSecondaryEmailChange.objects.filter( user=self.user) self.assertEqual(0, len(pending_secondary_email_changes)) account_recovery_objects = AccountRecovery.objects.filter( user=self.user) self.assertEqual(0, len(account_recovery_objects)) with patch('crum.get_current_request', return_value=self.fake_request): update = {"secondary_email": test_email} update_account_settings(self.user, update) pending_secondary_email_change = PendingSecondaryEmailChange.objects.get( user=self.user) self.assertIsNot(pending_secondary_email_change, None) self.assertEqual(pending_secondary_email_change.new_secondary_email, test_email) activate_secondary_email(self.fake_request, pending_secondary_email_change.activation_key) pending_secondary_email_changes = PendingSecondaryEmailChange.objects.filter( user=self.user) self.assertEqual(0, len(pending_secondary_email_changes)) account_recovery = AccountRecovery.objects.get(user=self.user) self.assertIsNot(account_recovery, None) self.assertEqual(account_recovery.secondary_email, test_email)