def test_email_change_request_email_taken_by_inactive_account(self): # Create a second user with the new email, but don't active them account_api.create_account(self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) # Request to change the original user's email to the email used by the inactive user response = self._change_email(self.NEW_EMAIL, self.OLD_PASSWORD) self.assertEquals(response.status_code, 200)
def test_password_change_inactive_user(self): # Log out the user created during test setup self.client.logout() # Create a second user, but do not activate it account_api.create_account(self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) # Send the view the email address tied to the inactive user response = self._change_password(email=self.NEW_EMAIL) self.assertEqual(response.status_code, 400)
def test_password_change_inactive_user(self): # Log out the user created during test setup self.client.logout() # Create a second user, but do not activate it account_api.create_account(self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) # Send the view the email address tied to the inactive user response = self._change_password(email=self.NEW_EMAIL) # Expect that the activation email is still sent, # since the user may have lost the original activation email. self.assertEqual(response.status_code, 200) self.assertEqual(len(mail.outbox), 1)
def test_email_change_request_email_taken_by_active_account(self): # Create/activate a second user with the new email activation_key = account_api.create_account(self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) account_api.activate_account(activation_key) # Request to change the original user's email to the email now used by the second user response = self._change_email(self.NEW_EMAIL, self.OLD_PASSWORD) self.assertEquals(response.status_code, 409)
def setUp(self): super(StudentAccountUpdateTest, self).setUp("student_account.urls") # Create/activate a new account activation_key = account_api.create_account(self.USERNAME, self.OLD_PASSWORD, self.OLD_EMAIL) account_api.activate_account(activation_key) # Login result = self.client.login(username=self.USERNAME, password=self.OLD_PASSWORD) self.assertTrue(result)
def test_login_and_registration_form_already_authenticated(self, url_name): # Create/activate a new account and log in activation_key = account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL) account_api.activate_account(activation_key) result = self.client.login(username=self.USERNAME, password=self.PASSWORD) self.assertTrue(result) # Verify that we're redirected to the dashboard response = self.client.get(reverse(url_name)) self.assertRedirects(response, reverse("dashboard"))
def setUp(self): super(StudentProfileViewTest, self).setUp("student_profile.urls") # Create/activate a new account activation_key = account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL) account_api.activate_account(activation_key) # Login result = self.client.login(username=self.USERNAME, password=self.PASSWORD) self.assertTrue(result)
def test_email_change_confirmation_email_already_exists(self): # Get an email change activation key email_activation_key = account_api.request_email_change(self.USERNAME, self.NEW_EMAIL, self.OLD_PASSWORD) # Create/activate a second user with the new email account_activation_key = account_api.create_account(self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) account_api.activate_account(account_activation_key) # Follow the link sent to the original user response = self.client.get(reverse('email_change_confirm', kwargs={'key': email_activation_key})) self.assertContains(response, "address you wanted to use is already used") # Verify that the email associated with the original account has not changed profile_info = profile_api.profile_info(self.USERNAME) self.assertEquals(profile_info['email'], self.OLD_EMAIL)
def test_email_change_confirmation_email_already_exists(self): # Get an email change activation key email_activation_key = account_api.request_email_change( self.USERNAME, self.NEW_EMAIL, self.OLD_PASSWORD) # Create/activate a second user with the new email account_activation_key = account_api.create_account( self.ALTERNATE_USERNAME, self.OLD_PASSWORD, self.NEW_EMAIL) account_api.activate_account(account_activation_key) # Follow the link sent to the original user response = self.client.get( reverse('email_change_confirm', kwargs={'key': email_activation_key})) self.assertContains(response, "address you wanted to use is already used") # Verify that the email associated with the original account has not changed profile_info = profile_api.profile_info(self.USERNAME) self.assertEquals(profile_info['email'], self.OLD_EMAIL)