Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Marinello
django-password-reset
Commits
3a6a2eb9
Commit
3a6a2eb9
authored
Sep 28, 2015
by
Bruno Renié
Browse files
Fix tests on all py/django combinations
parent
d033a52b
Changes
4
Hide whitespace changes
Inline
Side-by-side
password_reset/tests/settings.py
View file @
3a6a2eb9
...
...
@@ -15,3 +15,16 @@ INSTALLED_APPS = (
'password_reset'
,
'password_reset.tests'
,
)
MIGRATION_MODULES
=
{
'auth'
:
'django.contrib.auth.tests.migrations'
,
}
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'OPTIONS'
:
{
'loaders'
:
(
'django.template.loaders.app_directories.Loader'
,
),
},
}]
password_reset/tests/tests.py
View file @
3a6a2eb9
...
...
@@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.utils
import
timezone
from
django.utils.six
import
with_metaclass
from
django.utils.unittest
import
SkipTest
from
..forms
import
PasswordRecoveryForm
,
PasswordResetForm
...
...
@@ -23,7 +24,7 @@ class CustomUserVariants(type):
if
django
.
VERSION
>=
(
1
,
5
):
for
custom_user
in
[
'auth.CustomUser'
,
'auth.ExtensionUser'
]:
suffix
=
custom_user
.
lower
().
replace
(
'.'
,
'_'
)
for
key
,
fn
in
dct
.
items
():
for
key
,
fn
in
list
(
dct
.
items
()
)
:
if
key
.
startswith
(
'test'
)
and
'_CUSTOM_'
not
in
key
:
name
=
'{0}_CUSTOM_{1}'
.
format
(
key
,
suffix
)
dct
[
name
]
=
override_settings
(
...
...
@@ -45,9 +46,7 @@ def create_user():
return
get_user_model
().
_default_manager
.
create_user
(
*
args
,
**
kwargs
)
class
FormTests
(
TestCase
):
__metaclass__
=
CustomUserVariants
class
FormTests
(
with_metaclass
(
CustomUserVariants
,
TestCase
)):
def
test_username_input
(
self
):
User
=
get_user_model
()
if
User
is
CustomUser
:
...
...
@@ -208,9 +207,7 @@ class FormTests(TestCase):
user
.
password
)
class
ViewTests
(
TestCase
):
__metaclass__
=
CustomUserVariants
class
ViewTests
(
with_metaclass
(
CustomUserVariants
,
TestCase
)):
def
test_recover
(
self
):
self
.
user
=
create_user
()
url
=
reverse
(
'password_reset_recover'
)
...
...
password_reset/tests/urls.py
View file @
3a6a2eb9
from
django.conf.urls
import
url
,
patterns
from
django.conf.urls
import
url
from
..urls
import
urlpatterns
from
.
import
views
urlpatterns
+=
patterns
(
''
,
urlpatterns
+=
[
url
(
r
'^email_recover/$'
,
views
.
email_recover
,
name
=
'email_recover'
),
url
(
r
'^username_recover/$'
,
views
.
username_recover
,
name
=
'username_recover'
),
url
(
r
'^insensitive_recover/$'
,
views
.
insensitive_recover
,
name
=
'insensitive_recover'
),
)
]
password_reset/views.py
View file @
3a6a2eb9
import
datetime
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
,
RequestSite
from
django.contrib.sites.models
import
Site
from
django.core
import
signing
from
django.core.mail
import
send_mail
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
...
...
@@ -11,6 +11,11 @@ from django.template import loader
from
django.utils
import
timezone
from
django.views
import
generic
try
:
from
django.contrib.sites.requests
import
RequestSite
except
ImportError
:
from
django.contrib.sites.models
import
RequestSite
from
.forms
import
PasswordRecoveryForm
,
PasswordResetForm
from
.utils
import
get_user_model
,
get_username
from
.signals
import
user_recovers_password
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment