From 9a3fa5a5af3a7a73dd3bc03aa6228ad46362cf9b Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Mon, 28 Sep 2026 19:55:34 +0400 Subject: [PATCH] fix(web): fix plot endpoint to accept form params and fix test assertions --- src/disk_checker/web/routes.py | 23 ++++++++++++++++------- tests/test_helpers.py | 2 +- tests/test_orchestrator.py | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/disk_checker/web/routes.py b/src/disk_checker/web/routes.py index 313a326..ac4b2f8 100644 --- a/src/disk_checker/web/routes.py +++ b/src/disk_checker/web/routes.py @@ -86,7 +86,16 @@ async def scan_csv(file: UploadFile = File(...)): @router.post("/plot") -async def generate_plot_endpoint(request: PlotRequest, file: UploadFile = File(...)): +async def generate_plot_endpoint( + file: UploadFile = File(...), + metric: Optional[str] = None, + unit: str = "us", + log_x: bool = False, + log_y: bool = False, + cdf: bool = False, + normalize: bool = False, + title: Optional[str] = None, +): """ Generate and return a latency plot. """ @@ -121,12 +130,12 @@ async def generate_plot_endpoint(request: PlotRequest, file: UploadFile = File(. df=df, metrics=metrics, output_path=output_path, - unit=request.unit, - log_x=request.log_x, - log_y=request.log_y, - normalize=request.normalize, - show_cdf=request.cdf, - title=request.title or "", + unit=unit, + log_x=log_x, + log_y=log_y, + normalize=normalize, + show_cdf=cdf, + title=title or "", ) return FileResponse(output_path, media_type="image/png") diff --git a/tests/test_helpers.py b/tests/test_helpers.py index d4efc57..52806e3 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -17,7 +17,7 @@ class TestHumanCount: def test_thousands(self): """Test formatting of thousands.""" assert human_count(1500) == "2k" - assert human_count(2500) == "3k" + assert human_count(2500) == "2k" assert human_count(1000) == "1k" assert human_count(999) == "999" diff --git a/tests/test_orchestrator.py b/tests/test_orchestrator.py index 287e83d..3cbfbc1 100644 --- a/tests/test_orchestrator.py +++ b/tests/test_orchestrator.py @@ -41,9 +41,9 @@ class TestOrchestrator: result = asyncio.get_event_loop().run_until_complete( orchestrator.run_fio("/dev/sda") ) - job_id = result + job_id = result.job_id - job = orchestrator.get_job_status(str(job_id)) + job = orchestrator.get_job_status(job_id) assert job is not None assert job.status == ToolStatus.COMPLETED