@@ -215,3 +215,32 @@ def test_unsupported_methods_on_data(run_dracan_server):
215
215
# CONNECT
216
216
response = requests .request ("CONNECT" , url , headers = headers , timeout = 5 )
217
217
assert response .status_code == 405 # Method Not Allowed
218
+
219
+ def test_root_get_request (run_dracan_server ):
220
+ headers = {"Content-Type" : "application/json" , "X-API-KEY" : "test_key" , "Authorization" : "Bearer token123.abc.xyz" }
221
+ response = requests .get ("http://127.0.0.1:5000/" , headers = headers , timeout = 5 )
222
+ assert response .status_code == 200
223
+ assert response .json () == {'status' : 'root accessed' , 'method' : 'GET' }
224
+
225
+ def test_root_post_request (run_dracan_server ):
226
+ headers = {"Content-Type" : "application/json" , "X-API-KEY" : "test_key" , "Authorization" : "Bearer token123.abc.xyz" }
227
+ data = {"name" : "Jane" , "age" : 28 }
228
+ response = requests .post ("http://127.0.0.1:5000/" , json = data , headers = headers , timeout = 5 )
229
+ assert response .status_code == 201
230
+ assert response .json () == {'status' : 'root accessed' , 'method' : 'POST' , 'received_data' : data }
231
+
232
+ def test_root_put_request (run_dracan_server ):
233
+ headers = {"Content-Type" : "application/json" , "X-API-KEY" : "test_key" , "Authorization" : "Bearer token123.abc.xyz" }
234
+ data = {"name" : "Jane" , "age" : 29 }
235
+ response = requests .put ("http://127.0.0.1:5000/" , json = data , headers = headers , timeout = 5 )
236
+ assert response .status_code == 200
237
+ assert response .json () == {'status' : 'root accessed' , 'method' : 'PUT' , 'update_info' : data }
238
+
239
+ def test_root_delete_request (run_dracan_server ):
240
+ headers = {"Content-Type" : "application/json" , "X-API-KEY" : "test_key" , "Authorization" : "Bearer token123.abc.xyz" }
241
+ response = requests .delete ("http://127.0.0.1:5000/" , headers = headers , timeout = 5 )
242
+
243
+ def test_root_delete_request (run_dracan_server ):
244
+ headers = {"Content-Type" : "application/json" , "X-API-KEY" : "test_key" , "Authorization" : "Bearer token123.abc.xyz" }
245
+ response = requests .delete ("http://127.0.0.1:5000/" , headers = headers , timeout = 5 )
246
+ assert response .status_code == 204
0 commit comments