mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2026-02-22 05:23:31 +01:00
MAESTRO: align tests API response with selector
This commit is contained in:
@@ -31,7 +31,7 @@ This phase implements the test selection panel and analysis configuration contro
|
||||
- [x] `pytest backend/tests/api/test_tests_router.py` passes
|
||||
- [x] `GET /api/tests` returns all 106+ tests with id, name, and category
|
||||
- [x] All vitest tests pass: `npx vitest run src/__tests__/TestSelector.test.tsx src/__tests__/AnalysisControls.test.tsx`
|
||||
- [ ] Test selector renders all 106+ tests with checkboxes
|
||||
- [x] Test selector renders all 106+ tests with checkboxes
|
||||
- [ ] Select All / Deselect All buttons work correctly
|
||||
- [ ] Search/filter narrows visible tests by name
|
||||
- [ ] DNS resolution toggle defaults to off
|
||||
|
||||
@@ -3,13 +3,14 @@ from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.engine.scanner_registry import ScannerRegistry
|
||||
from app.schemas.tests import TestResponse
|
||||
from app.schemas.tests import TestListResponse, TestResponse
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["tests"])
|
||||
|
||||
|
||||
@router.get("/tests", response_model=list[TestResponse])
|
||||
def list_tests() -> list[TestResponse]:
|
||||
@router.get("/tests", response_model=TestListResponse)
|
||||
def list_tests() -> TestListResponse:
|
||||
registry = ScannerRegistry()
|
||||
tests = registry.list_tests()
|
||||
return [TestResponse.model_validate(test.model_dump()) for test in tests]
|
||||
response_tests = [TestResponse.model_validate(test.model_dump()) for test in tests]
|
||||
return TestListResponse(tests=response_tests, total_count=len(response_tests))
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from app.engine.models import Test
|
||||
|
||||
|
||||
class TestResponse(Test):
|
||||
pass
|
||||
|
||||
|
||||
class TestListResponse(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
tests: list[TestResponse]
|
||||
total_count: int = Field(alias="totalCount")
|
||||
|
||||
@@ -22,9 +22,13 @@ async def test_get_tests_returns_all_registered_tests() -> None:
|
||||
assert response.status_code == 200
|
||||
|
||||
payload = response.json()
|
||||
assert isinstance(payload, list)
|
||||
assert len(payload) == len(expected_lookup)
|
||||
assert isinstance(payload, dict)
|
||||
assert payload["totalCount"] == len(expected_lookup)
|
||||
|
||||
response_lookup = {item["id"]: item["name"] for item in payload}
|
||||
tests_payload = payload["tests"]
|
||||
assert isinstance(tests_payload, list)
|
||||
assert len(tests_payload) == len(expected_lookup)
|
||||
|
||||
response_lookup = {item["id"]: item["name"] for item in tests_payload}
|
||||
assert len(response_lookup) == len(expected_lookup)
|
||||
assert response_lookup == expected_lookup
|
||||
|
||||
Reference in New Issue
Block a user