Spaces:
Running
Running
Download tests/integration/test_api.py from iamfebin/algospaced-dsa: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/tests/integration/test_api.py
- Command line
-
hf download hf://spaces/iamfebin/algospaced-dsa/tests/integration/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/tests/integration/test_api.py
1.44 kB
| def test_get_public_config(client): | |
| """GET /api/config should return 200 with standard public configuration keys.""" | |
| response = client.get("/api/config") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert isinstance(data, dict) | |
| assert "apiKey" in data | |
| assert "projectId" in data | |
| def test_test_run_endpoint_unauthorized(client): | |
| """POST /api/reviews/test-run should reject unauthenticated requests with 401.""" | |
| payload = { | |
| "code": "def solve(): return 1", | |
| "test_cases": [{"input": [], "expected": 1}], | |
| } | |
| response = client.post("/api/reviews/test-run", json=payload) | |
| assert response.status_code == 401 | |
| assert "Missing or invalid Authorization header" in response.json()["detail"] | |
| def test_test_run_endpoint_sandbox_mode(client, sandbox_headers): | |
| """POST /api/reviews/test-run with Bearer sandbox should execute code and return results.""" | |
| payload = { | |
| "code": "def solve(x): return x * 2", | |
| "test_cases": [ | |
| {"input": [2], "expected": 4}, | |
| {"input": [5], "expected": 10}, | |
| ], | |
| "timeout": 3.0, | |
| } | |
| response = client.post("/api/reviews/test-run", json=payload, headers=sandbox_headers) | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["success"] is True | |
| assert data["status"] == "passed" | |
| assert data["total_tests"] == 2 | |
| assert data["passed_count"] == 2 | |