You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.4 KiB

from django.contrib.auth.hashers import make_password
from hc.test import BaseTestCase
class ChangeEmailTestCase(BaseTestCase):
def test_it_shows_form(self):
self.profile.token = make_password("foo", "change-email")
self.profile.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get("/accounts/change_email/foo/")
self.assertContains(r, "Change Account's Email Address")
def test_it_changes_password(self):
self.profile.token = make_password("foo", "change-email")
self.profile.save()
self.client.login(username="[email protected]", password="password")
payload = {"email": "[email protected]"}
self.client.post("/accounts/change_email/foo/", payload)
self.alice.refresh_from_db()
self.assertEqual(self.alice.email, "[email protected]")
self.assertFalse(self.alice.has_usable_password())
def test_it_requires_unique_email(self):
self.profile.token = make_password("foo", "change-email")
self.profile.save()
self.client.login(username="[email protected]", password="password")
payload = {"email": "[email protected]"}
r = self.client.post("/accounts/change_email/foo/", payload)
self.assertContains(r, "[email protected] is not available")
self.alice.refresh_from_db()
self.assertEqual(self.alice.email, "[email protected]")