Skip to content

Commit

Permalink
Merge pull request #69 from robdox/master
Browse files Browse the repository at this point in the history
Implement tox for testing against all python/django versions.
  • Loading branch information
iMerica committed May 16, 2020
2 parents a63a13e + 0bc943f commit 2a43288
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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!
This project began as a fork of `django-rest-auth`. Big thanks to everyone who contributed to that repo!
2 changes: 1 addition & 1 deletion dj_rest_auth/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
__author__ = '@iMerica https://github.com/iMerica'
__author_email__ = 'imichael@pm.me'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 @iMerica https://github.com/iMerica'
__copyright__ = 'Copyright 2020 @iMerica https://github.com/iMerica'
4 changes: 3 additions & 1 deletion dj_rest_auth/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
'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)
1 change: 0 additions & 1 deletion dj_rest_auth/registration/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
raise ImportError("allauth needs to be added to INSTALLED_APPS.")



class SocialAccountSerializer(serializers.ModelSerializer):
"""
serialize allauth SocialAccounts for use with a REST API
Expand Down
1 change: 0 additions & 1 deletion dj_rest_auth/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class ExampleProtectedView(APIView):
permission_classes = [permissions.IsAuthenticated]


def get(self, *args, **kwargs):
return Response(dict(success=True))

Expand Down
2 changes: 1 addition & 1 deletion dj_rest_auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def authenticate(self, request):
return None
else:
raw_token = self.get_raw_token(header)

if raw_token is None:
return None

Expand Down
1 change: 0 additions & 1 deletion dj_rest_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def logout(self, request):
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)
Expand Down
37 changes: 37 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2a43288

Please sign in to comment.