@@ -62,22 +62,24 @@ def cookies(self, request):
62
62
raise ValueError (f"Invalid token { request .param } " )
63
63
64
64
@pytest .mark .parametrize (
65
- ["path" , "headers" , "cookies" , "status_code" , "result" ],
65
+ ["path" , "method" , " headers" , "cookies" , "status_code" , "result" ],
66
66
(
67
- pytest .param ("/auth/" , "permission" , None , 200 , {"foo" : "auth" }, id = "auth_header_token_permission" ),
68
- pytest .param ("/auth/" , "role" , None , 200 , {"foo" : "auth" }, id = "auth_header_token_role" ),
67
+ pytest .param ("/auth/" , "get" , " permission" , None , 200 , {"foo" : "auth" }, id = "auth_header_token_permission" ),
68
+ pytest .param ("/auth/" , "get" , " role" , None , 200 , {"foo" : "auth" }, id = "auth_header_token_role" ),
69
69
pytest .param (
70
70
"/auth/" ,
71
+ "get" ,
71
72
"empty" ,
72
73
None ,
73
74
403 ,
74
75
{"detail" : "Insufficient permissions" , "error" : None , "status_code" : 403 },
75
76
id = "auth_header_token_empty" ,
76
77
),
77
- pytest .param ("/auth/" , None , "permission" , 200 , {"foo" : "auth" }, id = "auth_cookie_token_permission" ),
78
- pytest .param ("/auth/" , None , "role" , 200 , {"foo" : "auth" }, id = "auth_cookie_token_role" ),
78
+ pytest .param ("/auth/" , "get" , None , "permission" , 200 , {"foo" : "auth" }, id = "auth_cookie_token_permission" ),
79
+ pytest .param ("/auth/" , "get" , None , "role" , 200 , {"foo" : "auth" }, id = "auth_cookie_token_role" ),
79
80
pytest .param (
80
81
"/auth/" ,
82
+ "get" ,
81
83
None ,
82
84
"empty" ,
83
85
403 ,
@@ -86,28 +88,47 @@ def cookies(self, request):
86
88
),
87
89
pytest .param (
88
90
"/auth/" ,
91
+ "get" ,
89
92
None ,
90
93
None ,
91
94
401 ,
92
95
{"detail" : "Unauthorized" , "error" : None , "status_code" : 401 },
93
96
id = "auth_no_token" ,
94
97
),
95
98
pytest .param (
96
- "/no-auth/" , "permission" , None , 200 , {"foo" : "no-auth" }, id = "no_auth_header_token_permission"
99
+ "/no-auth/" , "get" , " permission" , None , 200 , {"foo" : "no-auth" }, id = "no_auth_header_token_permission"
97
100
),
98
- pytest .param ("/no-auth/" , "role" , None , 200 , {"foo" : "no-auth" }, id = "no_auth_header_token_role" ),
101
+ pytest .param ("/no-auth/" , "get" , " role" , None , 200 , {"foo" : "no-auth" }, id = "no_auth_header_token_role" ),
99
102
pytest .param (
100
- "/no-auth/" , None , "permission" , 200 , {"foo" : "no-auth" }, id = "no_auth_cookie_token_permission"
103
+ "/no-auth/" , "get" , None , "permission" , 200 , {"foo" : "no-auth" }, id = "no_auth_cookie_token_permission"
104
+ ),
105
+ pytest .param ("/no-auth/" , "get" , None , "role" , 200 , {"foo" : "no-auth" }, id = "no_auth_cookie_token_role" ),
106
+ pytest .param ("/no-auth/" , "get" , None , None , 200 , {"foo" : "no-auth" }, id = "no_auth_no_token" ),
107
+ pytest .param (
108
+ "/not-found/" ,
109
+ "get" ,
110
+ None ,
111
+ None ,
112
+ 404 ,
113
+ {"detail" : "Not Found" , "error" : "HTTPException" , "status_code" : 404 },
114
+ id = "not_found" ,
115
+ ),
116
+ pytest .param (
117
+ "/auth/" ,
118
+ "post" ,
119
+ None ,
120
+ None ,
121
+ 405 ,
122
+ {"detail" : "Method Not Allowed" , "error" : "HTTPException" , "status_code" : 405 },
123
+ id = "method_not_allowed" ,
101
124
),
102
- pytest .param ("/no-auth/" , None , "role" , 200 , {"foo" : "no-auth" }, id = "no_auth_cookie_token_role" ),
103
- pytest .param ("/no-auth/" , None , None , 200 , {"foo" : "no-auth" }, id = "no_auth_no_token" ),
104
125
),
105
126
indirect = ["headers" , "cookies" ],
106
127
)
107
- async def test_request (self , client , path , headers , cookies , status_code , result ):
128
+ async def test_request (self , client , path , method , headers , cookies , status_code , result ):
108
129
client .headers = headers
109
130
client .cookies = cookies
110
- response = await client .request ("get" , path )
131
+ response = await client .request (method , path )
111
132
112
133
assert response .status_code == status_code
113
134
assert response .json () == result
0 commit comments