Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Dec 15, 2018
1 parent eed1e3e commit 1c2eb43
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spirit/user/auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def clean_username(self):
raise forms.ValidationError(
_("The username is taken."))

return username
return self.cleaned_data["username"]

def clean_email2(self):
email = self.cleaned_data.get("email")
Expand Down
36 changes: 36 additions & 0 deletions spirit/user/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,42 @@ def test_user_views_denied_to_non_logged_users(self):
response = self.client.get(reverse('spirit:user:email-change-confirm', kwargs={'token': "foo"}))
self.assertEqual(response.status_code, 302)

@override_settings(ST_CASE_INSENSITIVE_USERNAMES=True)
def test_profile_creation_on_register_case_insensitive_user(self):
form_data = {
'username': 'UnIqUeFoO',
'email': 'some@some.com',
'email2': 'some@some.com',
'password': 'pass'}
response = self.client.post(
reverse('spirit:user:auth:register'), form_data)
expected_url = reverse('spirit:user:auth:login')
self.assertRedirects(response, expected_url, status_code=302)
self.assertTrue(
UserProfile.objects.filter(
nickname='UnIqUeFoO',
user__username='uniquefoo'
).exists())
self.assertFalse(
UserProfile.objects.filter(nickname='uniquefoo').exists())

@override_settings(ST_CASE_INSENSITIVE_USERNAMES=False)
def test_profile_creation_on_register_case_insensitive_user_off(self):
form_data = {
'username': 'UnIqUeFoO',
'email': 'some@some.com',
'email2': 'some@some.com',
'password': 'pass'}
response = self.client.post(
reverse('spirit:user:auth:register'), form_data)
expected_url = reverse('spirit:user:auth:login')
self.assertRedirects(response, expected_url, status_code=302)
self.assertTrue(
UserProfile.objects.filter(
nickname='UnIqUeFoO',
user__username='UnIqUeFoO'
).exists())

def test_profile_topics(self):
"""
profile user's topics
Expand Down

0 comments on commit 1c2eb43

Please sign in to comment.