Skip to content

Commit

Permalink
DRF 3.15 counteract new assertion for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Mar 9, 2024
1 parent 972141b commit 0aee902
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion tests/contrib/test_rest_framework_gis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from unittest import mock

import pytest
Expand Down Expand Up @@ -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)
],
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_extend_schema_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
22 changes: 11 additions & 11 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 0aee902

Please sign in to comment.