-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_coverage_boost.py
More file actions
63 lines (48 loc) · 2.38 KB
/
Copy pathtest_coverage_boost.py
File metadata and controls
63 lines (48 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""[FACT] Quick coverage boost tests.
[HYPOTHESIS] Testing small untested functions boosts coverage to 80%.
"""
from fastapi.testclient import TestClient
from helix_code.live_guardian import app
def test_validate_hypothesis_marker() -> None:
"""[FACT] Validate endpoint with hypothesis marker."""
with TestClient(app) as client:
response = client.post("/validate", params={"text": "[HYPOTHESIS] This may work."})
assert response.status_code == 200
data = response.json()
assert data["epistemic_markers"]["hypothesis"] is True
def test_validate_assumption_marker() -> None:
"""[FACT] Validate endpoint with assumption marker."""
with TestClient(app) as client:
response = client.post("/validate", params={"text": "[ASSUMPTION] Default config."})
assert response.status_code == 200
data = response.json()
assert data["epistemic_markers"]["assumption"] is True
def test_validate_multiple_markers() -> None:
"""[FACT] Validate endpoint with multiple markers."""
with TestClient(app) as client:
text = "[FACT] Sky is blue. [HYPOTHESIS] It may rain. [ASSUMPTION] Port 8080."
response = client.post("/validate", params={"text": text})
assert response.status_code == 200
data = response.json()
assert data["epistemic_markers"]["fact"] is True
assert data["epistemic_markers"]["hypothesis"] is True
assert data["epistemic_markers"]["assumption"] is True
def test_validate_imperative_violation() -> None:
"""[FACT] Validate endpoint detects imperatives."""
with TestClient(app) as client:
response = client.post("/validate", params={"text": "You must do this immediately."})
assert response.status_code == 200
data = response.json()
assert "you must" in data["agency_violations"]
def test_api_receipts_invalid_limit() -> None:
"""[FACT] /api/receipts handles invalid limit."""
with TestClient(app) as client:
response = client.get("/api/receipts?limit=invalid")
# FastAPI validates query params - may return 422
assert response.status_code in [200, 422]
def test_validate_no_params() -> None:
"""[FACT] POST /validate without text param."""
with TestClient(app) as client:
response = client.post("/validate")
# Should return 422 (missing required param)
assert response.status_code == 422