Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
username url regex compile with plus
Browse files Browse the repository at this point in the history
url unittest

depricated except with comma
  • Loading branch information
meomap committed Aug 24, 2016
1 parent dbad42c commit d935325
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
25 changes: 25 additions & 0 deletions userena/tests/tests_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.test import TestCase
from django.core.urlresolvers import reverse, NoReverseMatch


class UserenaUrlsTests(TestCase):
""" Test url resolve """

def test_resolve_email_with_plus_url(self):
username = 'foo+bar@example.com'
test_urls = [
'userena_signup_complete',
'userena_email_change',
'userena_email_change_complete',
'userena_email_confirm_complete',
'userena_disabled',
'userena_password_change',
'userena_password_change_complete',
'userena_profile_edit',
'userena_profile_detail',
]
for url_name in test_urls:
try:
reverse(url_name, kwargs={'username': username})
except NoReverseMatch as ex:
self.failed(ex)
18 changes: 9 additions & 9 deletions userena/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def merged_dict(dict_a, dict_b):
name='userena_password_reset_complete'),

# Signup
url(r'^(?P<username>[\@\.\w-]+)/signup/complete/$',
url(r'^(?P<username>[\@\.\+\w-]+)/signup/complete/$',
userena_views.direct_to_user_template,
{'template_name': 'userena/signup_complete.html',
'extra_context': {'userena_activation_required': userena_settings.USERENA_ACTIVATION_REQUIRED,
Expand All @@ -66,14 +66,14 @@ def merged_dict(dict_a, dict_b):
name='userena_activate_retry'),

# Change email and confirm it
url(r'^(?P<username>[\@\.\w-]+)/email/$',
url(r'^(?P<username>[\@\.\+\w-]+)/email/$',
userena_views.email_change,
name='userena_email_change'),
url(r'^(?P<username>[\@\.\w-]+)/email/complete/$',
url(r'^(?P<username>[\@\.\+\w-]+)/email/complete/$',
userena_views.direct_to_user_template,
{'template_name': 'userena/email_change_complete.html'},
name='userena_email_change_complete'),
url(r'^(?P<username>[\@\.\w-]+)/confirm-email/complete/$',
url(r'^(?P<username>[\@\.\+\w-]+)/confirm-email/complete/$',
userena_views.direct_to_user_template,
{'template_name': 'userena/email_confirm_complete.html'},
name='userena_email_confirm_complete'),
Expand All @@ -82,27 +82,27 @@ def merged_dict(dict_a, dict_b):
name='userena_email_confirm'),

# Disabled account
url(r'^(?P<username>[\@\.\w-]+)/disabled/$',
url(r'^(?P<username>[\@\.\+\w-]+)/disabled/$',
userena_views.disabled_account,
{'template_name': 'userena/disabled.html'},
name='userena_disabled'),

# Change password
url(r'^(?P<username>[\@\.\w-]+)/password/$',
url(r'^(?P<username>[\@\.\+\w-]+)/password/$',
userena_views.password_change,
name='userena_password_change'),
url(r'^(?P<username>[\@\.\w-]+)/password/complete/$',
url(r'^(?P<username>[\@\.\+\w-]+)/password/complete/$',
userena_views.direct_to_user_template,
{'template_name': 'userena/password_complete.html'},
name='userena_password_change_complete'),

# Edit profile
url(r'^(?P<username>[\@\.\w-]+)/edit/$',
url(r'^(?P<username>[\@\.\+\w-]+)/edit/$',
userena_views.profile_edit,
name='userena_profile_edit'),

# View profiles
url(r'^(?P<username>(?!(signout|signup|signin)/)[\@\.\w-]+)/$',
url(r'^(?P<username>(?!(signout|signup|signin)/)[\@\.\+\w-]+)/$',
userena_views.profile_detail,
name='userena_profile_detail'),
url(r'^page/(?P<page>[0-9]+)/$',
Expand Down

0 comments on commit d935325

Please sign in to comment.