def test_view_set(self):
    request = APIRequestFactory().get('')
cat_detail = CatViewSet.as_view({'get': 'retrieve'})
cat = Cat.objects.create(name='bob')
response = cat_detail(request, pk=cat.pk)
self.assertEqual(response.status_code, 200)
Django Rest Framework — как протестировать ViewSet?