From 0aee9020ee84e402e72c2a43e2e9fe78c66fba69 Mon Sep 17 00:00:00 2001 From: "T. Franzel" Date: Sat, 9 Mar 2024 01:05:49 +0100 Subject: [PATCH] DRF 3.15 counteract new assertion for tests --- README.rst | 2 +- setup.py | 1 + tests/contrib/test_rest_framework_gis.py | 6 +++++- tests/test_extend_schema_view.py | 4 ++-- tests/test_regressions.py | 22 +++++++++++----------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index a0ffcb4f..e1544657 100644 --- a/README.rst +++ b/README.rst @@ -63,7 +63,7 @@ Requirements - Python >= 3.7 - Django (2.2, 3.2, 4.0, 4.1, 4.2, 5.0) -- Django REST Framework (3.10.3, 3.11, 3.12, 3.13, 3.14) +- Django REST Framework (3.10.3, 3.11, 3.12, 3.13, 3.14, 3.15) Installation ------------ diff --git a/setup.py b/setup.py index fbe55a9c..fcfea8a3 100644 --- a/setup.py +++ b/setup.py @@ -86,6 +86,7 @@ def get_version(package): 'Framework :: Django :: 4.0', 'Framework :: Django :: 4.1', 'Framework :: Django :: 4.2', + 'Framework :: Django :: 5.0', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', diff --git a/tests/contrib/test_rest_framework_gis.py b/tests/contrib/test_rest_framework_gis.py index 5fa1582b..345a76cb 100644 --- a/tests/contrib/test_rest_framework_gis.py +++ b/tests/contrib/test_rest_framework_gis.py @@ -1,3 +1,4 @@ +import re from unittest import mock import pytest @@ -87,7 +88,10 @@ class PlainViewset(mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.Ge assert_schema( generate_schema(None, patterns=router.urls), 'tests/contrib/test_rest_framework_gis.yml', - transforms=django_transforms, + transforms=[ + *django_transforms, + lambda x: re.sub(r'\s+required:\n\s+- count\n\s+- results', '', x, flags=re.M) + ], ) diff --git a/tests/test_extend_schema_view.py b/tests/test_extend_schema_view.py index 1cd04408..059237c8 100644 --- a/tests/test_extend_schema_view.py +++ b/tests/test_extend_schema_view.py @@ -85,8 +85,8 @@ def raw_action(self, request): router = routers.SimpleRouter() router.register('x', XViewSet) -router.register('y', YViewSet) -router.register('z', ZViewSet) +router.register('y', YViewSet, basename='alt1') +router.register('z', ZViewSet, basename='alt2') urlpatterns = router.urls diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 81879fa3..a0629298 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -1546,10 +1546,10 @@ class XViewset5(viewsets.ModelViewSet): router = routers.SimpleRouter() router.register('child_by_id', XViewset1) - router.register('child_by_parent_id', XViewset2) - router.register('child_by_parent_id_alt', XViewset3) - router.register('grand_child_by_grand_parent_id', XViewset4) - router.register('grand_child_by_grand_parent_id_alt', XViewset5) + router.register('child_by_parent_id', XViewset2, basename='alt1') + router.register('child_by_parent_id_alt', XViewset3, basename='alt2') + router.register('grand_child_by_grand_parent_id', XViewset4, basename='alt3') + router.register('grand_child_by_grand_parent_id_alt', XViewset5, basename='alt4') schema = generate_schema(None, patterns=router.urls) @@ -1615,7 +1615,7 @@ class JournalEntryAltViewset(viewsets.ModelViewSet): router = routers.SimpleRouter() router.register('journal', JournalEntryViewset) - router.register('journal_alt', JournalEntryAltViewset) + router.register('journal_alt', JournalEntryAltViewset, basename='alt') schema = generate_schema(None, patterns=router.urls) @@ -2650,7 +2650,7 @@ class InsectViewSet(AnimalViewSet): router = routers.SimpleRouter() router.register('api/mammals', MammalViewSet) - router.register('api/insects', InsectViewSet) + router.register('api/insects', InsectViewSet, basename='alt') schema = generate_schema(None, patterns=router.urls) assert schema['paths']['/api/mammals/notes/']['get']['summary'] == 'List mammals.' @@ -2678,8 +2678,8 @@ class ZViewSet(YViewSet): router = routers.SimpleRouter() router.register('x', XViewSet) - router.register('y', YViewSet) - router.register('z', ZViewSet) + router.register('y', YViewSet, basename='alt1') + router.register('z', ZViewSet, basename='alt2') schema = generate_schema(None, patterns=router.urls) resp = { c: get_response_schema(schema['paths'][f'/{c.lower()}/{{id}}/']['get']) @@ -2707,7 +2707,7 @@ class YViewSet(XViewSet): router = routers.SimpleRouter() router.register('x', XViewSet) - router.register('y', YViewSet) + router.register('y', YViewSet, basename='alt') schema = generate_schema(None, patterns=router.urls) op = { c: schema['paths'][f'/{c.lower()}/{{id}}/']['get'] for c in ['X', 'Y'] @@ -3215,8 +3215,8 @@ class X3ViewSet(X2ViewSet): router = routers.SimpleRouter() router.register('x1', X1ViewSet) - router.register('x2', X2ViewSet) - router.register('x3', X3ViewSet) + router.register('x2', X2ViewSet, basename='alt1') + router.register('x3', X3ViewSet, basename='alt2') schema = generate_schema(None, patterns=router.urls) assert '/x1/' not in schema['paths']