I'm writing the unittests for django models, in some of the models i need to make third party HTTP call. Which i do not want to execute while runing the test for example:
def signup_request_post_save_signal(sender, **kwargs):
if not kwargs.get('created'):
return
instance = kwargs.get('instance')
# make API call
In the test code, using factory-boy module for dummy data to create an instance of SignupRequest.
from factory import django
class SignupRequestFactory(django.DjangoModelFactory):
class Meta:
model = User
django_get_or_create = ('username',)
While saving the instance of the SignupRequest, is there any way to avoid HTTP call in the post save signal?
I have not used this mock/patch, is in this scenario Is mock/patch applicable or not ?
Aucun commentaire:
Enregistrer un commentaire