Skip to content

Commit 0e21a6e

Browse files
Refactor API smoke tests for clarity and structure
1 parent 5d09e76 commit 0e21a6e

1 file changed

Lines changed: 7 additions & 28 deletions

File tree

api/tests/test_api_smoke.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
"""
23
Basic smoke tests for the API service.
34
These run in GitHub Actions on every push — no local setup needed.
@@ -6,13 +7,8 @@
67
"""
78

89
import importlib
9-
import sys
1010
from pathlib import Path
1111

12-
# ---------------------------------------------------------------------------
13-
# Helpers
14-
# ---------------------------------------------------------------------------
15-
1612

1713
def _can_import(module: str) -> bool:
1814
"""Return True if module is importable, False otherwise."""
@@ -23,11 +19,6 @@ def _can_import(module: str) -> bool:
2319
return False
2420

2521

26-
# ---------------------------------------------------------------------------
27-
# Structural tests — always pass regardless of implementation state
28-
# ---------------------------------------------------------------------------
29-
30-
3122
class TestProjectStructure:
3223
"""Verify the api/ directory has expected files."""
3324

@@ -48,12 +39,7 @@ def test_no_syntax_errors(self):
4839
ast.parse(f.read_text(encoding="utf-8"))
4940
except SyntaxError as e:
5041
errors.append(f"{f}: {e}")
51-
assert not errors, f"Syntax errors found:\n" + "\n".join(errors)
52-
53-
54-
# ---------------------------------------------------------------------------
55-
# Dependency presence tests
56-
# ---------------------------------------------------------------------------
42+
assert not errors, "Syntax errors found:\n" + "\n".join(errors)
5743

5844

5945
class TestCoreDependencies:
@@ -75,11 +61,6 @@ def test_pydantic_importable(self):
7561
), "pydantic must be importable — required by FastAPI"
7662

7763

78-
# ---------------------------------------------------------------------------
79-
# FastAPI app smoke test (only runs if app module exists)
80-
# ---------------------------------------------------------------------------
81-
82-
8364
class TestFastAPIAppSmoke:
8465
"""
8566
Light smoke tests for the FastAPI app.
@@ -89,7 +70,6 @@ class TestFastAPIAppSmoke:
8970

9071
def _get_app(self):
9172
"""Try to import the FastAPI app — return None if not ready."""
92-
# Adjust 'api.main' or 'api.app' to match your actual module path
9373
for module_path in ("api.main", "main", "app"):
9474
try:
9575
mod = importlib.import_module(module_path)
@@ -103,7 +83,6 @@ def test_app_importable(self):
10383
"""App module should exist once api/ is wired up."""
10484
app = self._get_app()
10585
if app is None:
106-
# Not yet implemented — emit a warning instead of failing
10786
import warnings
10887

10988
warnings.warn(
@@ -119,14 +98,14 @@ def test_health_endpoint(self):
11998
try:
12099
from fastapi.testclient import TestClient
121100
except ImportError:
122-
return # httpx not installed, skip
101+
return
123102

124103
app = self._get_app()
125104
if app is None:
126-
return # not yet implemented
105+
return
127106

128107
client = TestClient(app)
129108
response = client.get("/health")
130-
assert (
131-
response.status_code == 200
132-
), f"GET /health returned {response.status_code} — add a /health endpoint"
109+
assert response.status_code == 200, (
110+
f"GET /health returned {response.status_code} — add a /health endpoint"
111+
)

0 commit comments

Comments
 (0)