def assertTextResponse(self, request: IRequest) -> str: """ Assert that the response is text and return the text. """ self.assertResponseCode(request, http.OK) self.assertResponseContentType(request, ContentType.text.value) # FIXME: Check encoding, default to UTF-8 return cast(bytes, request.getWrittenData()).decode()
def assertJSONResponse(self, request: IRequest, status: int = http.OK) -> str: """ Assert that the response is JSON and return the JSON text. """ self.assertResponseCode(request, status) self.assertResponseContentType(request, ContentType.json.value) # FIXME: Check encoding, default to UTF-8 return cast(bytes, request.getWrittenData()).decode()