I have a django view like this
# Django view
from some_module import f2
def f1(request, version):
# some code
f2(**kargs)
# more code
return HTTPResponse(response)
The function f2 is in another module
# some_module
def f2(**kargs):
# some code
The Django view is part of an API so, the request and response are in json
How do I :
- write a unit test for this function while mocking the request
- mock f2, which is a database based function and avoid database connections entirely
Aucun commentaire:
Enregistrer un commentaire