From ca4d22c8c9a9238353525f654e58b5cd9ee7d02a Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 13 Jan 2016 21:46:38 +0600 Subject: [PATCH 1/8] added django 1.9 to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 18ed856..e207330 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ install: - pip install tox env: + - TOX_ENV=django.1.9 - TOX_ENV=django.1.8.lts, - TOX_ENV=django.1.7 From 8c30c843667446e4e06e9d0f97a1610564076e35 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 13 Jan 2016 21:51:17 +0600 Subject: [PATCH 2/8] added django 1.9 and guardian 1.4 on tox --- tox.ini | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 432e0e8..5a37613 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = + django.1.9 django.1.8.lts, django.1.7 @@ -12,18 +13,24 @@ commands= {envbindir}/django-admin.py test --settings=settings {posargs} +[testenv:django.1.9] +deps= + {[testenv]deps} + Django==1.9.1 + djangorestframework==3.3.2 + django-guardian==1.4.1 [testenv:django.1.8.lts] deps= {[testenv]deps} - Django==1.8.7 - djangorestframework==3.3.1 - django-guardian==1.3.2 + Django==1.8.8 + djangorestframework==3.3.2 + django-guardian==1.4.1 [testenv:django.1.7] deps= {[testenv]deps} Django==1.7.11 - djangorestframework==3.3.1 - django-guardian==1.3.2 + djangorestframework==3.3.2 + django-guardian==1.4.1 From c44452c0723c222406c93a289fcbcdcd94843238 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 13 Jan 2016 21:58:25 +0600 Subject: [PATCH 3/8] remove obsolete code from settings --- tests_app/settings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests_app/settings.py b/tests_app/settings.py index 352cc18..1566c84 100644 --- a/tests_app/settings.py +++ b/tests_app/settings.py @@ -126,8 +126,7 @@ import django -if django.VERSION < (1, 3): - INSTALLED_APPS += ('staticfiles',) + TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' From 6f16f42c5f4ede3386957c67766172919fd100fd Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 13 Jan 2016 22:10:24 +0600 Subject: [PATCH 4/8] remove obsolete code from compat.py --- rest_framework_extensions/compat.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rest_framework_extensions/compat.py b/rest_framework_extensions/compat.py index 2887229..1b621b5 100644 --- a/rest_framework_extensions/compat.py +++ b/rest_framework_extensions/compat.py @@ -12,16 +12,13 @@ from django.conf import settings # Try to import six from Django, fallback to included `six`. -try: - from django.utils import six -except ImportError: - from rest_framework import six +from django.utils import six + # location of patterns, url, include changes in 1.4 onwards -try: - from django.conf.urls import patterns, url, include -except ImportError: - from django.conf.urls.defaults import patterns, url, include + +from django.conf.urls import url, include + # Handle django.utils.encoding rename: # smart_unicode -> smart_text From aa5f791e0c63d985ad1e2320f0f8baac48763852 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 9 Mar 2016 11:50:18 +0600 Subject: [PATCH 5/8] adjust version --- tox.ini | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tox.ini b/tox.ini index 5a37613..c9e2b26 100644 --- a/tox.ini +++ b/tox.ini @@ -16,21 +16,21 @@ commands= [testenv:django.1.9] deps= {[testenv]deps} - Django==1.9.1 - djangorestframework==3.3.2 - django-guardian==1.4.1 + Django>=1.9,<1.10 + djangorestframework>=3.3.2 + django-guardian>=1.4.1 [testenv:django.1.8.lts] deps= {[testenv]deps} - Django==1.8.8 - djangorestframework==3.3.2 - django-guardian==1.4.1 + Django>=1.8,<1.9 + djangorestframework>=3.3.2 + django-guardian>=1.4.1 [testenv:django.1.7] deps= {[testenv]deps} - Django==1.7.11 - djangorestframework==3.3.2 - django-guardian==1.4.1 + Django>=1.7,<1.8 + djangorestframework>=3.3.2 + django-guardian>=1.4.1 From 0b2f83669e7c93500b6c3035affbb00eef593431 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 9 Mar 2016 12:34:12 +0600 Subject: [PATCH 6/8] fix import error --- .../permissions/extended_django_object_permissions/tests.py | 3 +-- tests_app/tests/functional/routers/tests.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py b/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py index 227c753..1825a06 100644 --- a/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py +++ b/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import json -from django.test import TestCase -from django.utils import unittest +import django.test from django.contrib.auth.models import User, Group, Permission from django.contrib.auth.management import create_permissions from django.db.models import get_app, get_models diff --git a/tests_app/tests/functional/routers/tests.py b/tests_app/tests/functional/routers/tests.py index 92ae227..7e523b5 100644 --- a/tests_app/tests/functional/routers/tests.py +++ b/tests_app/tests/functional/routers/tests.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from django.test import TestCase -from django.utils import unittest +import django.test + from rest_framework_extensions.compat_drf import get_lookup_allowed_symbols from rest_framework_extensions.utils import get_rest_framework_features From 976b6d85750677ae76e55f25f6bf637e8a1290d6 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 30 Mar 2016 12:31:35 +0600 Subject: [PATCH 7/8] adjust tests codes --- tests_app/tests/functional/routers/tests.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests_app/tests/functional/routers/tests.py b/tests_app/tests/functional/routers/tests.py index 7e523b5..b34bfb5 100644 --- a/tests_app/tests/functional/routers/tests.py +++ b/tests_app/tests/functional/routers/tests.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -import django.test + +from django.test import TestCase from rest_framework_extensions.compat_drf import get_lookup_allowed_symbols @@ -26,10 +27,7 @@ def test_urls_have_trailing_slash_by_default(self): self.assertIsNotNone(get_url_pattern_by_regex_pattern(urls, exp), msg=msg) -@unittest.skipUnless( - get_rest_framework_features()['router_trailing_slash'], - "Current DRF version doesn't support Router trailing_slash" -) + class TestTrailingSlashRemoved(TestCase): def test_urls_can_have_trailing_slash_removed(self): router = ExtendedSimpleRouter(trailing_slash=False) From f2e29e223e7c0e7340f4aba2d9d067cbb1874e36 Mon Sep 17 00:00:00 2001 From: auvipy Date: Wed, 30 Mar 2016 12:47:55 +0600 Subject: [PATCH 8/8] adjust tests of object permission --- .../tests.py | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py b/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py index 1825a06..5b2cba0 100644 --- a/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py +++ b/tests_app/tests/functional/permissions/extended_django_object_permissions/tests.py @@ -1,17 +1,15 @@ # -*- coding: utf-8 -*- import json -import django.test from django.contrib.auth.models import User, Group, Permission from django.contrib.auth.management import create_permissions -from django.db.models import get_app, get_models +from django.db.models import get_app from django.contrib.contenttypes.models import ContentType from rest_framework import status from rest_framework_extensions.test import APITestCase -from rest_framework_extensions.compat import guardian, get_model_name -from rest_framework_extensions.utils import get_rest_framework_features +from rest_framework_extensions.compat import get_model_name from tests_app.testutils import basic_auth_header from .urls import urlpatterns @@ -44,7 +42,7 @@ def setUp(self): app_label = PermissionsComment._meta.app_label f = '{0}_{1}'.format perms = { - 'view': f('view', model_name), + 'view': f('view', model_name), 'change': f('change', model_name), 'delete': f('delete', model_name) } @@ -73,21 +71,22 @@ def setUp(self): self.credentials[user.username] = basic_auth_header(user.username, 'password') -@unittest.skipIf( - not get_rest_framework_features()['django_object_permissions_class'], - "Current DRF version doesn't support DjangoObjectPermissions" -) + class ExtendedDjangoObjectPermissionsTest_should_inherit_standard(ExtendedDjangoObjectPermissionTestMixin, APITestCase): urls = urlpatterns # Delete def test_can_delete_permissions(self): - response = self.client.delete('/comments/1/', **{'HTTP_AUTHORIZATION': self.credentials['deleteonly']}) + response = self.client.delete( + '/comments/1/', + **{'HTTP_AUTHORIZATION': self.credentials['deleteonly']}) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) def test_cannot_delete_permissions(self): - response = self.client.delete('/comments/1/', **{'HTTP_AUTHORIZATION': self.credentials['readonly']}) + response = self.client.delete( + '/comments/1/', + **{'HTTP_AUTHORIZATION': self.credentials['readonly']}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) # Update @@ -127,11 +126,15 @@ def test_cannot_update_permissions_non_existing(self): # Read def test_can_read_permissions(self): - response = self.client.get('/comments/1/', **{'HTTP_AUTHORIZATION': self.credentials['readonly']}) + response = self.client.get( + '/comments/1/', + **{'HTTP_AUTHORIZATION': self.credentials['readonly']}) self.assertEqual(response.status_code, status.HTTP_200_OK) def test_cannot_read_permissions(self): - response = self.client.get('/comments/1/', **{'HTTP_AUTHORIZATION': self.credentials['writeonly']}) + response = self.client.get( + '/comments/1/', + **{'HTTP_AUTHORIZATION': self.credentials['writeonly']}) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) # Read list @@ -152,10 +155,6 @@ def test_cannot_read_list_permissions(self): self.assertListEqual(response.data, []) -@unittest.skipIf( - not get_rest_framework_features()['django_object_permissions_class'], - "Current DRF version doesn't support DjangoObjectPermissions" -) class ExtendedDjangoObjectPermissionsTest_without_hiding_forbidden_objects(ExtendedDjangoObjectPermissionTestMixin, APITestCase): urls = urlpatterns