So, I've been trying to write unit tests for a function that returns a JSONResponse
that contains a status_code
and content
. The function looks like this:
def exception_handler(request):
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content=jsonable_encoder({"detail": NotFoundException} if is_development() else {}),
)
I'm testing for two cases: is_development()
returns True
or False
. When I'm calling the function to test it like this: response = exception_handler(request)
I can access response.status_code
but not response.content
. Why is that? I wanna access the content in order to check if it is correct.