def test_username_updates(self): user = self.create_user('*****@*****.**') self.login_as(user) email = UserEmail(user=user, email='*****@*****.**') email.save() self.client.post(self.path, data={ 'primary': '', 'new_primary_email': '*****@*****.**' }, follow=True) user = User.objects.get(id=user.id) assert user.username != '*****@*****.**' assert user.username == '*****@*****.**'
def test_remove_alt_email(self): user = self.create_user('*****@*****.**') self.login_as(user) email = UserEmail(user=user, email='*****@*****.**') email.save() resp = self.client.get(self.path) self.assertIn('*****@*****.**', resp.content) resp = self.client.post( self.path, data={ 'remove': '', 'email': '*****@*****.**'}, follow=True) self.assertNotIn('*****@*****.**', resp.content) assert '*****@*****.**' not in (email.email for email in user.emails.all())