Hi guys,
I would like to sure my new open source project which might be helpful for some of you.
The
drf-api-action Python package is designed to elevate your
testing experience for
Django Rest Framework (DRF) REST endpoints. With the custom decorator api-action, this package empowers you to effortlessly test your REST endpoints as if they were conventional functions.
Features:
Simplified Testing: Easily test DRF REST endpoints using the api-action decorator, treating them like regular functions.
Seamless Integration: Replace DRF's action decorator with api-action in your WebViewSet for a smooth transition.
for example:
class DummyView(APIRestMixin, ModelViewSet):
queryset = DummyModel.objects.all()
serializer_class = DummySerializer
@action_api(detail=True, methods=["get"], serializer_class=DummySerializer)
def dummy(self, request, **kwargs):
serializer = self.get_serializer(instance=self.get_object())
return Response(data=serializer.data, status=status.HTTP_200_OK)
def test_dummy():
api = DummyView()
result = api.dummy(pk=1)
assert result['dummy_int'] == 1
Hope you will find it helpful, and be more than happy to invite you to use this package let me know what you think
Thank you for being such a great community!
Ori