def test_debug_logging_hooks(self, session, hook, text, capture): session.add_hook(hook) session.get("http://httpbin.org/get") assert len(capture.records) == 2 assert capture.records[1].levelno == logging.DEBUG assert text in capture.records[1].msg
def test_response_verify_response_success(self, session): session.get("http://httpbin.org/get").vr([200, 201])
def test_response_verify_response_error(self, session): with pytest.raises(ValueError): session.get("http://httpbin.org/get").vr(400)
def test_response_converter_adding_function_dataclass(self, session): session.add_hook(ResponseDataclassConverterHook) res = session.get("http://httpbin.org/get").vr() assert getattr(res, "structure") assert getattr(res, "verify_response") assert getattr(res, "vr")
def test_request_converter_non_dataclass(self, session): session.add_hook(RequestDataclassConverterHook) res = session.get("http://httpbin.org/get", data="test") assert res.request.body == "test"
def test_request_converter_dataclass_class(self, session): session.add_hook(RequestDataclassConverterHook) res = session.get( "http://httpbin.org/get", data=ExampleDataclass("test") ) assert res.request.body == json.dumps({"test": "test"}).encode("utf-8")
def test_response_converter_adding_function(self, session): session.add_hook(ResponseAttrsConverterHook) res = session.get("http://httpbin.org/get") assert getattr(res, "structure")
def test_info_logging_hooks(self, session, hook, text, capture): session.add_hook(hook) session.get("http://httpbin.org/get") assert len(capture.records) == 1 assert capture.records[0].levelno == logging.INFO assert text in capture.records[0].msg