Skip to content

Commit

Permalink
Drop checks of Django versions that reached end of life
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed May 22, 2024
1 parent d876ab5 commit b9ef165
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 57 deletions.
49 changes: 22 additions & 27 deletions example_app/urls.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
# -*- coding: utf-8 -*-
from django.utils import version as django_version
from django.urls import path

from rest_framework.urlpatterns import format_suffix_patterns
from .views import (
OrderListCreateEndpoint, OrderRetrieveUpdateDestroyEndpoint,
OrderRetrieveUpdateEndpoint, OrderCreateWithGenericEndpoint,
OrderListWithGenericEndpoint, OrderRetrieveWithGenericEndpoint,
OrderUpdateWithGenericEndpoint, OrderCreateWithMixinEndpoint,
OrderUpdateWithMixinEndpoint, OrderListWithoutReadSerializerEndpoint,
OrderListWithMixinEndpoint, OrderRetrieveWithMixinEndpoint,
OrderViewset)

if django_version.get_complete_version() < (2, 0, 0):
from django.conf.urls import url
else:
from django.urls import re_path as url
from .views import (
OrderCreateWithGenericEndpoint, OrderCreateWithMixinEndpoint, OrderListCreateEndpoint, OrderListWithGenericEndpoint,
OrderListWithMixinEndpoint, OrderListWithoutReadSerializerEndpoint, OrderRetrieveUpdateDestroyEndpoint,
OrderRetrieveUpdateEndpoint, OrderRetrieveWithGenericEndpoint, OrderRetrieveWithMixinEndpoint,
OrderUpdateWithGenericEndpoint, OrderUpdateWithMixinEndpoint, OrderViewset
)


urlpatterns = [
url(r'^orders-list-without-read-serializer/$',
path('orders-list-without-read-serializer/',
OrderListWithoutReadSerializerEndpoint.as_view(),
name='list_without_read_serializer'),

url(r'^orders/$', OrderListCreateEndpoint.as_view(), name='list_create'),
url(r'^orders/(?P<pk>[0-9]+)$', OrderRetrieveUpdateDestroyEndpoint.as_view(),
path('orders/', OrderListCreateEndpoint.as_view(), name='list_create'),
path('orders/(?P<pk>[0-9]+)', OrderRetrieveUpdateDestroyEndpoint.as_view(),
name='retrieve_update_destroy'),
url(r'^orders-retrieve-update/(?P<pk>[0-9]+)$', OrderRetrieveUpdateEndpoint.as_view(),
path('orders-retrieve-update/(?P<pk>[0-9]+)', OrderRetrieveUpdateEndpoint.as_view(),
name='retrieve_update'),
url(r'^orders-list-generic-view/$', OrderListWithGenericEndpoint.as_view(),
path('orders-list-generic-view/', OrderListWithGenericEndpoint.as_view(),
name='list'),
url(r'^orders-retrieve-generic-view/(?P<pk>[0-9]+)$',
path('orders-retrieve-generic-view/(?P<pk>[0-9]+)',
OrderRetrieveWithGenericEndpoint.as_view(),
name='retrieve'),
url(r'^orders-create-generic-view/$', OrderCreateWithGenericEndpoint.as_view(),
path('orders-create-generic-view/', OrderCreateWithGenericEndpoint.as_view(),
name='create'),
url(r'^orders-update-generic-view/(?P<pk>[0-9]+)$', OrderUpdateWithGenericEndpoint.as_view(),
path('orders-update-generic-view/(?P<pk>[0-9]+)', OrderUpdateWithGenericEndpoint.as_view(),
name='update'),

url(r'^orders-list-mixin/$', OrderListWithMixinEndpoint.as_view(),
path('orders-list-mixin/', OrderListWithMixinEndpoint.as_view(),
name='list_mixin'),
url(r'^orders-retrieve-mixin/(?P<pk>[0-9]+)$', OrderRetrieveWithMixinEndpoint.as_view(),
path('orders-retrieve-mixin/(?P<pk>[0-9]+)', OrderRetrieveWithMixinEndpoint.as_view(),
name='retrieve_mixin'),
url(r'^orders-create-mixin/$', OrderCreateWithMixinEndpoint.as_view(),
path('orders-create-mixin/', OrderCreateWithMixinEndpoint.as_view(),
name='create_mixin'),
url(r'^orders-update-mixin/(?P<pk>[0-9]+)$', OrderUpdateWithMixinEndpoint.as_view(),
path('orders-update-mixin/(?P<pk>[0-9]+)', OrderUpdateWithMixinEndpoint.as_view(),
name='update_mixin'),

url(r'^orders-viewset/$',
path('orders-viewset/',
OrderViewset.as_view({
'get': 'list',
'post': 'create',
}),
name='viewset_list_create'),
url(r'^orders-viewset/(?P<pk>[0-9]+)$',
path('orders-viewset/(?P<pk>[0-9]+)',
OrderViewset.as_view({
'get': 'retrieve',
'put': 'update',
Expand Down
15 changes: 5 additions & 10 deletions tests/test_generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@

from __future__ import absolute_import, unicode_literals

from django.utils import version as django_version
from django.urls import reverse

from model_bakery import baker

from test_utils.base_tests import (
BaseTestCase, TestListRequestSuccess, TestRetrieveRequestSuccess,
TestCreateRequestSuccess, TestUpdateRequestSuccess)
from example_app.serializers import OrderCreateSerializer, OrderListSerializer


if django_version.get_complete_version() < (2, 0, 0):
from django.core.urlresolvers import reverse # pylint: disable=no-name-in-module,import-error
else:
from django.urls import reverse # pylint: disable=no-name-in-module,import-error
from test_utils.base_tests import (
BaseTestCase, TestCreateRequestSuccess, TestListRequestSuccess, TestRetrieveRequestSuccess, TestUpdateRequestSuccess
)


class OrderListCreateEndpointTests(
Expand Down
15 changes: 5 additions & 10 deletions tests/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@

from __future__ import absolute_import, unicode_literals

from django.utils import version as django_version
from django.urls import reverse

from model_bakery import baker

from test_utils.base_tests import (
BaseTestCase, TestListRequestSuccess, TestRetrieveRequestSuccess,
TestCreateRequestSuccess, TestUpdateRequestSuccess)
from example_app.serializers import OrderCreateSerializer, OrderListSerializer


if django_version.get_complete_version() < (2, 0, 0):
from django.core.urlresolvers import reverse # pylint: disable=no-name-in-module,import-error
else:
from django.urls import reverse # pylint: disable=no-name-in-module,import-error
from test_utils.base_tests import (
BaseTestCase, TestCreateRequestSuccess, TestListRequestSuccess, TestRetrieveRequestSuccess, TestUpdateRequestSuccess
)


class OrderCreateWithMixinEndpointTests(BaseTestCase, TestCreateRequestSuccess):
Expand Down
15 changes: 5 additions & 10 deletions tests/test_viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@

from __future__ import absolute_import, unicode_literals

from django.utils import version as django_version
from django.urls import reverse

from model_bakery import baker

from test_utils.base_tests import (
BaseTestCase, TestListRequestSuccess, TestRetrieveRequestSuccess,
TestCreateRequestSuccess, TestUpdateRequestSuccess)
from example_app.serializers import OrderCreateSerializer, OrderListSerializer


if django_version.get_complete_version() < (2, 0, 0):
from django.core.urlresolvers import reverse # pylint: disable=no-name-in-module,import-error
else:
from django.urls import reverse # pylint: disable=no-name-in-module,import-error
from test_utils.base_tests import (
BaseTestCase, TestCreateRequestSuccess, TestListRequestSuccess, TestRetrieveRequestSuccess, TestUpdateRequestSuccess
)


class OrderViewsetListCreateTests(
Expand Down

0 comments on commit b9ef165

Please sign in to comment.