@@ -14,7 +14,10 @@ async def test_aiohttp_integration_valid_input(client: TestClient):
14
14
given_query_string = {
15
15
"q" : "string" ,
16
16
}
17
- given_headers = {"content-type" : "application/json" }
17
+ given_headers = {
18
+ "content-type" : "application/json" ,
19
+ "Host" : "localhost" ,
20
+ }
18
21
given_data = {"param1" : 1 }
19
22
expected_status_code = 200
20
23
expected_response_data = {"data" : "data" }
@@ -31,6 +34,42 @@ async def test_aiohttp_integration_valid_input(client: TestClient):
31
34
assert response_data == expected_response_data
32
35
33
36
37
+ async def test_aiohttp_integration_invalid_server (client : TestClient , request ):
38
+ if "no_validation" in request .node .name :
39
+ pytest .skip ("No validation for given handler." )
40
+ # Given
41
+ given_query_string = {
42
+ "q" : "string" ,
43
+ }
44
+ given_headers = {
45
+ "content-type" : "application/json" ,
46
+ "Host" : "petstore.swagger.io" ,
47
+ }
48
+ given_data = {"param1" : 1 }
49
+ expected_status_code = 400
50
+ expected_response_data = {
51
+ "errors" : [
52
+ {
53
+ "message" : (
54
+ "Server not found for "
55
+ "http://petstore.swagger.io/browse/12/"
56
+ ),
57
+ }
58
+ ]
59
+ }
60
+ # When
61
+ response = await client .post (
62
+ "/browse/12/" ,
63
+ params = given_query_string ,
64
+ json = given_data ,
65
+ headers = given_headers ,
66
+ )
67
+ response_data = await response .json ()
68
+ # Then
69
+ assert response .status == expected_status_code
70
+ assert response_data == expected_response_data
71
+
72
+
34
73
async def test_aiohttp_integration_invalid_input (
35
74
client : TestClient , response_getter , request
36
75
):
@@ -40,7 +79,10 @@ async def test_aiohttp_integration_invalid_input(
40
79
given_query_string = {
41
80
"q" : "string" ,
42
81
}
43
- given_headers = {"content-type" : "application/json" }
82
+ given_headers = {
83
+ "content-type" : "application/json" ,
84
+ "Host" : "localhost" ,
85
+ }
44
86
given_data = {"param1" : "string" }
45
87
response_getter .return_value = {"data" : 1 }
46
88
expected_status_code = 400
0 commit comments