feat: улучшить agentic-readiness — добавить CI, проверки конфигурации и тесты
This commit is contained in:
+28
-2
@@ -39,7 +39,6 @@ async def test_scan_not_found(client):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_scans_with_filters(client):
|
||||
# Filter parameters smoke test — should not 500
|
||||
for params in [
|
||||
"?flagged=true&search=test&status=completed&sort_by=id&sort_dir=asc",
|
||||
"?flagged=false&search=nonexistent&sort_by=total_findings",
|
||||
@@ -48,6 +47,11 @@ async def test_list_scans_with_filters(client):
|
||||
]:
|
||||
resp = await client.get(f"/api/v1/scans{params}")
|
||||
assert resp.status_code == 200, f"Failed on: {params}"
|
||||
data = resp.json()
|
||||
assert "scans" in data
|
||||
assert "total" in data
|
||||
assert "limit" in data
|
||||
assert isinstance(data["scans"], list)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -58,6 +62,8 @@ async def test_scan_stats_with_data(client, sample_flagged_scan):
|
||||
assert data["total_scans"] == 1
|
||||
assert data["flagged_scans"] == 1
|
||||
assert data["total_findings"] == 1
|
||||
assert data["recent_flagged"] == 1
|
||||
assert isinstance(data["top_rules"], list)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -73,6 +79,8 @@ async def test_scans_csv_export_with_filter(client, sample_flagged_scan):
|
||||
resp = await client.get("/api/v1/scans/export?flagged=true")
|
||||
assert resp.status_code == 200
|
||||
assert sample_flagged_scan.package_name in resp.text
|
||||
assert sample_flagged_scan.ecosystem in resp.text
|
||||
assert "text/csv" in resp.headers["content-type"]
|
||||
|
||||
|
||||
# --- Packages ---
|
||||
@@ -84,18 +92,25 @@ async def test_list_packages_empty(client):
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["total"] == 0
|
||||
assert data["packages"] == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_packages_with_filters(client):
|
||||
for params in [
|
||||
"?search=test&sort_by=name&sort_dir=asc",
|
||||
"?flagged=false&sort_by=last_scanned_at",
|
||||
"?flagged=False&sort_by=last_scanned_at",
|
||||
"?ecosystem=pypi",
|
||||
"?sort_by=invalid",
|
||||
]:
|
||||
resp = await client.get(f"/api/v1/packages{params}")
|
||||
assert resp.status_code == 200, f"Failed on: {params}"
|
||||
data = resp.json()
|
||||
assert "packages" in data
|
||||
assert "total" in data
|
||||
assert "limit" in data
|
||||
assert isinstance(data["packages"], list)
|
||||
assert len(data["packages"]) <= data["total"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -111,6 +126,8 @@ async def test_packages_csv_export_with_filter(client, sample_flagged_scan):
|
||||
resp = await client.get("/api/v1/packages/export?flagged=true")
|
||||
assert resp.status_code == 200
|
||||
assert sample_flagged_scan.package_name in resp.text
|
||||
assert sample_flagged_scan.package_version in resp.text
|
||||
assert "text/csv" in resp.headers["content-type"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -140,6 +157,7 @@ async def test_list_findings_empty(client):
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["total"] == 0
|
||||
assert data["findings"] == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -160,6 +178,11 @@ async def test_list_findings_with_filters(client, sample_flagged_scan):
|
||||
]:
|
||||
resp = await client.get(f"/api/v1/findings{params}")
|
||||
assert resp.status_code == 200, f"Failed on: {params}"
|
||||
data = resp.json()
|
||||
assert "findings" in data
|
||||
assert "total" in data
|
||||
assert "limit" in data
|
||||
assert isinstance(data["findings"], list)
|
||||
|
||||
|
||||
# --- Web UI ---
|
||||
@@ -190,12 +213,14 @@ async def test_web_ui_scans(client):
|
||||
async def test_web_ui_scans_with_search(client):
|
||||
resp = await client.get("/scans?search=nonexistent&status=completed&sort_by=id&sort_dir=asc")
|
||||
assert resp.status_code == 200
|
||||
assert "search" in resp.text.lower() or "nonexistent" in resp.text
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_web_ui_scans_page_out_of_range(client):
|
||||
resp = await client.get("/scans?page=999")
|
||||
assert resp.status_code == 200
|
||||
assert "page" in resp.text.lower() or "scan" in resp.text.lower()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -223,6 +248,7 @@ async def test_web_ui_packages(client):
|
||||
async def test_web_ui_packages_with_search(client):
|
||||
resp = await client.get("/packages?search=test&sort_by=name&sort_dir=asc")
|
||||
assert resp.status_code == 200
|
||||
assert "search" in resp.text.lower() or "test" in resp.text or "package" in resp.text.lower()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user