diff --git a/accounts/tests/test_edit_profile_view.py b/accounts/tests/test_edit_profile_view.py index 34f4647..1893cf9 100644 --- a/accounts/tests/test_edit_profile_view.py +++ b/accounts/tests/test_edit_profile_view.py @@ -11,6 +11,26 @@ class EditProfileViewTestCase(TestCase): user_a.set_password('password123456donkey') user_a.save() Account.objects.create(user=user_a) + User.objects.create(username='user_c', email='user_c@example.com') + + def test_edit_profile_view_email_already_exists(self): + self.client.login(username='user_a', password='password123456donkey') + response = self.client.post(reverse('accounts:edit_profile'), { + 'email': 'user_c@example.com', + 'first_name': 'User_a', + 'last_name': 'Smith', + 'twitter_handle': '@user_a', + 'password': 'password123456donkey', + }, follow=True) + self.assertEquals(response.status_code, 200) + self.assertTemplateUsed(response, 'base_form.html') + user_a = User.objects.get(username='user_a') + self.assertEquals(user_a.email, 'user_a@example.com') + self.assertEquals(user_a.first_name, '') + self.assertEquals(user_a.account.twitter_handle, '@Twitter') + self.assertEquals(response.request['PATH_INFO'], '/accounts/edit-profile/') + msg = "An account already exists with this email address." + self.assertEquals(response.content.decode('utf-8').count(msg), 1) def test_edit_profile_view_no_login(self): response = self.client.post(reverse('accounts:edit_profile'), {