Skip to content

Commit

Permalink
updated tests with asserts for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz committed May 1, 2024
1 parent 23af30d commit 0b15763
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/bin/test_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 0b15763

Please sign in to comment.