diff --git a/README.md b/README.md index deefdb5..0430a08 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,21 @@ The easiest way to run test coverage is with [`coverage`](https://pypi.org/proje which runs the tests against all supported Django installs. To run the test coverage within a virtualenv, run `coverage run ./runtests.py` from the repository directory then run `coverage report`. +#### Tox + +Testing may also be done using [`tox`](https://pypi.org/project/tox/), which +will run the tests against all supported combinations of python and django. + +Install tox, either globally or within a virtualenv, and then simply run `tox` +from the repository directory. As there are many combinations, you may run them +in [`parallel`](https://tox.readthedocs.io/en/latest/config.html#cmdoption-tox-p) +using `tox --parallel`. + +The `tox.ini` includes an environment for testing code [`coverage`](https://pypi.org/project/coverage/) +and you can run it and view this report with `tox -e coverage`. + +Linting may also be performed via [`flake8`](https://pypi.org/project/flake8/) +by running `tox -e flake8`. ### Documentation @@ -59,4 +74,4 @@ View the full documentation here: https://dj-rest-auth.readthedocs.io/en/latest/ ### Acknowledgements -This project began as a fork of `django-rest-auth`. Big thanks to everyone who contributed to that repo! \ No newline at end of file +This project began as a fork of `django-rest-auth`. Big thanks to everyone who contributed to that repo! diff --git a/dj_rest_auth/__version__.py b/dj_rest_auth/__version__.py index dd67bed..5b7a5aa 100644 --- a/dj_rest_auth/__version__.py +++ b/dj_rest_auth/__version__.py @@ -5,4 +5,4 @@ __version__ = '1.0.5' __author__ = '@iMerica https://github.com/iMerica' __author_email__ = 'imichael@pm.me' __license__ = 'MIT' -__copyright__ = 'Copyright 2020 @iMerica https://github.com/iMerica' \ No newline at end of file +__copyright__ = 'Copyright 2020 @iMerica https://github.com/iMerica' diff --git a/dj_rest_auth/app_settings.py b/dj_rest_auth/app_settings.py index 784a691..fe6e6a2 100644 --- a/dj_rest_auth/app_settings.py +++ b/dj_rest_auth/app_settings.py @@ -33,6 +33,8 @@ PasswordResetConfirmSerializer = import_callable(serializers.get( 'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer )) -PasswordChangeSerializer = import_callable(serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer)) +PasswordChangeSerializer = import_callable( + serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer) +) JWT_AUTH_COOKIE = getattr(settings, 'JWT_AUTH_COOKIE', None) diff --git a/dj_rest_auth/registration/serializers.py b/dj_rest_auth/registration/serializers.py index fc7c92b..7d9d4a0 100644 --- a/dj_rest_auth/registration/serializers.py +++ b/dj_rest_auth/registration/serializers.py @@ -17,7 +17,6 @@ except ImportError: raise ImportError("allauth needs to be added to INSTALLED_APPS.") - class SocialAccountSerializer(serializers.ModelSerializer): """ serialize allauth SocialAccounts for use with a REST API diff --git a/dj_rest_auth/tests/urls.py b/dj_rest_auth/tests/urls.py index e2c786e..f1796d6 100644 --- a/dj_rest_auth/tests/urls.py +++ b/dj_rest_auth/tests/urls.py @@ -21,7 +21,6 @@ from . import django_urls class ExampleProtectedView(APIView): permission_classes = [permissions.IsAuthenticated] - def get(self, *args, **kwargs): return Response(dict(success=True)) diff --git a/dj_rest_auth/utils.py b/dj_rest_auth/utils.py index 7cbf3ad..e1ef77a 100644 --- a/dj_rest_auth/utils.py +++ b/dj_rest_auth/utils.py @@ -45,7 +45,7 @@ try: return None else: raw_token = self.get_raw_token(header) - + if raw_token is None: return None diff --git a/dj_rest_auth/views.py b/dj_rest_auth/views.py index b5fcdb8..c968334 100644 --- a/dj_rest_auth/views.py +++ b/dj_rest_auth/views.py @@ -146,7 +146,6 @@ class LogoutView(APIView): from rest_framework_simplejwt.exceptions import TokenError from rest_framework_simplejwt.tokens import RefreshToken - cookie_name = getattr(settings, 'JWT_AUTH_COOKIE', None) if cookie_name: response.delete_cookie(cookie_name) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..484802b --- /dev/null +++ b/tox.ini @@ -0,0 +1,37 @@ +# tox (https://tox.readthedocs.io/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +# Running this tox will test against all supported version +# combinations of python and django as described at the following +# https://docs.djangoproject.com/en/3.0/faq/install/#what-python-version-can-i-use-with-django +# https://endoflife.date/django +[tox] +skipsdist = true +envlist = + python{3.5,3.6,3.7,3.8}-django22 + python{3.6,3.7,3.8}-django30 + +[testenv] +commands = + python ./runtests.py +deps = + -rdev-requirements.txt + django22: Django>=2.2,<2.3 + django30: Django>=3.0,<3.1 + +# Configuration for coverage and flake8 is being set in `./setup.cfg` +[testenv:coverage] +commands = + coverage run ./runtests.py + coverage report +deps = + -rdev-requirements.txt + +[testenv:flake8] +changedir = {toxinidir}/dj_rest_auth +commands = + flake8 . +deps = + flake8==3.8.1