From 0b15763ed7fcf9c3d8fa866259cc5ad334bbbd83 Mon Sep 17 00:00:00 2001 From: Zach Fuller Date: Tue, 30 Apr 2024 17:51:29 -0700 Subject: [PATCH] updated tests with asserts for headers --- tests/bin/test_server/server.py | 4 +++- tests/test_requests.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/bin/test_server/server.py b/tests/bin/test_server/server.py index c6d1f96..e37fc90 100644 --- a/tests/bin/test_server/server.py +++ b/tests/bin/test_server/server.py @@ -11,7 +11,9 @@ async def index() -> Response: @post("/foo") async def post_foo(request: Request) -> Response: data = await request.json() - return json(data) + resp: Response = json(data) + resp.add_header(b"X-Test", b"Test") + return resp @get("/exception") diff --git a/tests/test_requests.py b/tests/test_requests.py index e7fdbf2..da3b537 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -43,7 +43,12 @@ def test_send_requests(request_map_collection: List[RequestMap]) -> None: for response in responses: assert response.status_code == 200 assert response.error is None - + if response.request_map.http_op == "GET": + assert response.headers is None + elif response.request_map.http_op == "POST": + assert response.headers is not None + assert "X-Test" in response.headers + assert "Test" == response.headers["X-Test"] def test_send_requests_with_exceptions( request_map_collection: List[RequestMap],