Fixes tests

This commit is contained in:
Michael 2020-02-29 19:46:32 -06:00
parent b2300a4981
commit 41dce8885a
5 changed files with 39 additions and 21 deletions

0
README.md Normal file
View File

View File

@ -1,30 +1,45 @@
# Moved in Django 1.8 from django to tests/auth_tests/urls.py # Moved in Django 1.8 from django to tests/auth_tests/urls.py
from django.conf.urls import url from django.conf.urls import url
from django.contrib.auth import views
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.urls import urlpatterns from django.contrib.auth.urls import urlpatterns
try:
from django.contrib.auth.views import (
logout, login, password_reset,
password_change, password_reset_confirm
)
except ImportError:
from django.contrib.auth.views import (
LoginView, LogoutView, PasswordResetView,
PasswordChangeView, PasswordResetConfirmView
)
logout = LogoutView.as_view()
login = LoginView.as_view()
password_reset = PasswordResetView.as_view()
password_change = PasswordChangeView.as_view()
password_reset_confirm = PasswordResetConfirmView.as_view()
# special urls for auth test cases # special urls for auth test cases
urlpatterns += [ urlpatterns += [
url(r'^logout/custom_query/$', views.logout, dict(redirect_field_name='follow')), url(r'^logout/custom_query/$', logout, dict(redirect_field_name='follow')),
url(r'^logout/next_page/$', views.logout, dict(next_page='/somewhere/')), url(r'^logout/next_page/$', logout, dict(next_page='/somewhere/')),
url(r'^logout/next_page/named/$', views.logout, dict(next_page='password_reset')), url(r'^logout/next_page/named/$', logout, dict(next_page='password_reset')),
url(r'^password_reset_from_email/$', views.password_reset, dict(from_email='staffmember@example.com')), url(r'^password_reset_from_email/$', password_reset, dict(from_email='staffmember@example.com')),
url(r'^password_reset/custom_redirect/$', views.password_reset, dict(post_reset_redirect='/custom/')), url(r'^password_reset/custom_redirect/$', password_reset, dict(post_reset_redirect='/custom/')),
url(r'^password_reset/custom_redirect/named/$', views.password_reset, dict(post_reset_redirect='password_reset')), url(r'^password_reset/custom_redirect/named/$', password_reset, dict(post_reset_redirect='password_reset')),
url(r'^password_reset/html_email_template/$', views.password_reset, url(r'^password_reset/html_email_template/$', password_reset,
dict(html_email_template_name='registration/html_password_reset_email.html')), dict(html_email_template_name='registration/html_password_reset_email.html')),
url(r'^reset/custom/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', url(r'^reset/custom/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.password_reset_confirm, password_reset_confirm,
dict(post_reset_redirect='/custom/')), dict(post_reset_redirect='/custom/')),
url(r'^reset/custom/named/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', url(r'^reset/custom/named/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.password_reset_confirm, password_reset_confirm,
dict(post_reset_redirect='password_reset')), dict(post_reset_redirect='password_reset')),
url(r'^password_change/custom/$', views.password_change, dict(post_change_redirect='/custom/')), url(r'^password_change/custom/$', password_change, dict(post_change_redirect='/custom/')),
url(r'^password_change/custom/named/$', views.password_change, dict(post_change_redirect='password_reset')), url(r'^password_change/custom/named/$', password_change, dict(post_change_redirect='password_reset')),
url(r'^admin_password_reset/$', views.password_reset, dict(is_admin_site=True)), url(r'^admin_password_reset/$', password_reset, dict(is_admin_site=True)),
url(r'^login_required/$', login_required(views.password_reset)), url(r'^login_required/$', login_required(password_reset)),
url(r'^login_required_login_url/$', login_required(views.password_reset, login_url='/somewhere/')), url(r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')),
] ]

View File

@ -1,8 +1,11 @@
import os import os
import sys import sys
import logging
PROJECT_ROOT = os.path.abspath(os.path.split(os.path.split(__file__)[0])[0]) PROJECT_ROOT = os.path.abspath(os.path.split(os.path.split(__file__)[0])[0])
logging.disable(logging.CRITICAL)
ROOT_URLCONF = 'urls' ROOT_URLCONF = 'urls'
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = '%s/staticserve' % PROJECT_ROOT STATIC_ROOT = '%s/staticserve' % PROJECT_ROOT
@ -70,7 +73,6 @@ REST_FRAMEWORK = {
} }
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.humanize', 'django.contrib.humanize',
'django.contrib.contenttypes', 'django.contrib.contenttypes',

View File

@ -3,8 +3,8 @@
import os import os
import sys import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' os.environ['DJANGO_SETTINGS_MODULE'] = 'dj_rest_auth.tests.settings'
test_dir = os.path.join(os.path.dirname(__file__), 'rest_auth') test_dir = os.path.join(os.path.dirname(__file__), 'dj_rest_auth')
sys.path.insert(0, test_dir) sys.path.insert(0, test_dir)
import django import django

View File

@ -5,7 +5,7 @@ from setuptools import setup, find_packages
here = os.path.dirname(os.path.abspath(__file__)) here = os.path.dirname(os.path.abspath(__file__))
f = open(os.path.join(here, 'README.rst')) f = open(os.path.join(here, 'README.md'))
long_description = f.read().strip() long_description = f.read().strip()
f.close() f.close()
@ -13,12 +13,13 @@ f.close()
setup( setup(
name='dj-rest-auth', name='dj-rest-auth',
version='0.9.5', version='0.9.5',
author='Sumit Chachra', author='iMerica',
author_email='chachra@tivix.com', author_email='imichael@pm.me',
url='http://github.com/iMerica/dj-rest-auth', url='http://github.com/iMerica/dj-rest-auth',
description='Create a set of REST API endpoints for Authentication and Registration', description='Create a set of REST API endpoints for Authentication and Registration',
packages=find_packages(), packages=find_packages(),
long_description=long_description, long_description=long_description,
long_description_content_type='text/markdown',
keywords='django rest auth registration rest-framework django-registration api', keywords='django rest auth registration rest-framework django-registration api',
zip_safe=False, zip_safe=False,
install_requires=[ install_requires=[