Skip to content

Commit

Permalink
pt 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Apr 12, 2024
1 parent ff678b7 commit ee7ac5c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/integrate_openapi/validate_request_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def client() -> RestClient:
},
},
"required": ["rank"],
"additionalProperties": False,
}
}
}
Expand Down Expand Up @@ -295,23 +296,35 @@ async def test_010__invalid(server: Callable[[], RestClient]) -> None:
# with pytest.raises(requests.HTTPError) as e:
# # extra arg(s) -- NOTE: THESE ARE ACTUALLY OK
# await rc.request("GET", "/foo/args", {"name": "dwayne", "car": "vroom"})
with pytest.raises(requests.HTTPError) as e:
with pytest.raises(
requests.HTTPError,
match=re.escape(
f"Query parameter error: rank for url: {rc.address}/foo/args?rank=abc"
),
) as e:
# bad type
await rc.request("GET", "/foo/args", {"rank": "abc"})
print(e.value)
assert e.value.response.status_code == 400
#
with pytest.raises(requests.HTTPError) as e:
with pytest.raises(
requests.HTTPError,
match=re.escape(
f"'rank' is a required property for url: {rc.address}/foo/args"
),
) as e:
# missing arg(s)
await rc.request("POST", "/foo/args")
print(e.value)
assert e.value.response.status_code == 400
with pytest.raises(requests.HTTPError) as e:
# extra arg(s)
await rc.request("POST", "/foo/args", {"rank": 123, "suv": "gas"})
print(e.value)
assert e.value.response.status_code == 400
with pytest.raises(requests.HTTPError) as e:
# bad type
await rc.request("POST", "/foo/args", {"rank": "abc"})
print(e.value)
assert e.value.response.status_code == 400

# args + url params
# NOTE: not testing the compound cases, since that's exponentially more tests for
Expand Down

0 comments on commit ee7ac5c

Please sign in to comment.