예제 #1
0
 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
예제 #2
0
 def test_response_verify_response_success(self, session):
     session.get("http://httpbin.org/get").vr([200, 201])
예제 #3
0
 def test_response_verify_response_error(self, session):
     with pytest.raises(ValueError):
         session.get("http://httpbin.org/get").vr(400)
예제 #4
0
 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")
예제 #5
0
 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"
예제 #6
0
 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")
예제 #7
0
 def test_response_converter_adding_function(self, session):
     session.add_hook(ResponseAttrsConverterHook)
     res = session.get("http://httpbin.org/get")
     assert getattr(res, "structure")
예제 #8
0
 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