I am not clear on how to properly use unittest.mock. I need to test APIView using rest_framework.test.APITestCase.client. But I don't need to call one of methods.
class MyClass(MyMixin):
def do_some_stuff(self, request):
self.should_be_called_in_the_test()
self.should_not_be_called_in_the_test()
class MyView(views.APIView):
def post(self, request):
my_object = MyClass()
my_object.do_some_stuff(request)
return Response(status=status.HTTP_200_OK)
#test.py:
class MyViewTest(APITestCase):
def test_post_request(self):
url = reverse('my-view-url')
# How properly skip call of "should_not_be_called_in_the_test()" ?
response = self.client.post(url, data)
# some asserts...