88
99from backend .app import app , rate_limiter
1010
11-
1211client = TestClient (app )
1312
1413
@@ -25,16 +24,23 @@ def test_e2e_workflow():
2524 b64 = base64 .b64encode (raw ).decode ()
2625 r2 = client .post (
2726 "/api/optimize" ,
28- json = {"model_file" : b64 , "config" : {"quantize" : "int8" , "target_device" : "raspberry_pi" }},
27+ json = {
28+ "model_file" : b64 ,
29+ "config" : {"quantize" : "int8" , "target_device" : "raspberry_pi" },
30+ },
2931 )
3032 assert r2 .status_code == 200
3133 opt_b64 = r2 .json ()["optimized_model" ]
3234
3335 # 3) Benchmark
34- r3 = client .post ("/api/benchmark" , json = {"original_model" : b64 , "optimized_model" : opt_b64 })
36+ r3 = client .post (
37+ "/api/benchmark" , json = {"original_model" : b64 , "optimized_model" : opt_b64 }
38+ )
3539 assert r3 .status_code == 200
3640 data = r3 .json ()
37- assert "original_stats" in data and "optimized_stats" in data and "improvement" in data
41+ assert (
42+ "original_stats" in data and "optimized_stats" in data and "improvement" in data
43+ )
3844
3945
4046def test_concurrent_requests ():
@@ -63,10 +69,19 @@ def test_rate_limit_enforced():
6369 rate_limiter .window_started .clear ()
6470 # Make 3 compile calls, third should hit 429
6571 cfg = 'model_path="m.tflite"\n '
66- assert client .post ("/api/compile" , json = {"config_file" : cfg , "filename" : "a.ef" }).status_code == 200
67- assert client .post ("/api/compile" , json = {"config_file" : cfg , "filename" : "a.ef" }).status_code == 200
72+ assert (
73+ client .post (
74+ "/api/compile" , json = {"config_file" : cfg , "filename" : "a.ef" }
75+ ).status_code
76+ == 200
77+ )
78+ assert (
79+ client .post (
80+ "/api/compile" , json = {"config_file" : cfg , "filename" : "a.ef" }
81+ ).status_code
82+ == 200
83+ )
6884 r = client .post ("/api/compile" , json = {"config_file" : cfg , "filename" : "a.ef" })
6985 assert r .status_code in (200 , 429 )
7086 finally :
7187 rate_limiter .capacity = old_cap
72-
0 commit comments