Skip to content

Commit

Permalink
add pagination / custom action usage test #277
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Feb 8, 2021
1 parent e59c332 commit 967bfbf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,27 @@ class YViewset(XViewset):
validate_schema(schema)


def test_pagination_disabled_on_action(no_warnings):
class XViewset(viewsets.ReadOnlyModelViewSet):
queryset = SimpleModel.objects.all()
serializer_class = SimpleSerializer
pagination_class = pagination.LimitOffsetPagination

@extend_schema(responses={'200': SimpleSerializer(many=True)})
@action(methods=['GET'], detail=False, pagination_class=None)
def custom_action(self):
pass # pragma: no cover

class YViewset(XViewset):
serializer_class = SimpleSerializer

schema = generate_schema('/x/', YViewset)
assert 'PaginatedSimpleList' in get_response_schema(schema['paths']['/x/']['get'])['$ref']
assert 'Simple' in get_response_schema(
schema['paths']['/x/custom_action/']['get']
)['items']['$ref']


@mock.patch(
'drf_spectacular.settings.spectacular_settings.SECURITY',
[{'apiKeyAuth': []}]
Expand Down

0 comments on commit 967bfbf

Please sign in to comment.