Skip to content

Commit 436457e

Browse files
mpk-droidclaude
andcommitted
fix: catch RouteNotFoundError, guard missing env vars, register marker
- Catch RouteNotFoundError alongside MakeTargetError in the deployed_agent fixture so route lookup failures produce a clean test failure instead of an uncaught exception - Validate BASE_URL and MODEL_ID are set before writing .env, failing with a clear message instead of a raw KeyError - Register @pytest.mark.integration in root pyproject.toml to suppress PytestUnknownMarkWarning Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3b4a44e commit 436457e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

agents/langgraph/react_agent/tests/integration/test_deployment.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from integration.utils import (
88
MakeTargetError,
9+
RouteNotFoundError,
910
get_route,
1011
health_check,
1112
run_make,
@@ -24,6 +25,12 @@ def agent_dir(repo_root):
2425

2526
def _write_env_file(agent_dir, container_image):
2627
"""Write a .env file so Makefile targets can source it."""
28+
missing = [v for v in ("BASE_URL", "MODEL_ID") if v not in os.environ]
29+
if missing:
30+
pytest.fail(
31+
f"Missing required env vars: {', '.join(missing)}. "
32+
"Set them in the CI workflow or export locally."
33+
)
2734
env_path = agent_dir / ".env"
2835
env_path.write_text(
2936
f"API_KEY={os.environ.get('API_KEY', 'not-needed')}\n"
@@ -54,8 +61,8 @@ def deployed_agent(cluster_auth, agent_dir):
5461

5562
yield route_url
5663

57-
except MakeTargetError as exc:
58-
pytest.fail(f"Deployment failed at make {exc.target}: {exc}")
64+
except (MakeTargetError, RouteNotFoundError) as exc:
65+
pytest.fail(f"Deployment failed: {exc}")
5966

6067
finally:
6168
if deployed:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ markers = [
5353
"adversarial: Agent-level security/safety tests (PII, API keys, dangerous ops)",
5454
"model_baseline: Model-level tests (prompt injection resistance) - not agent-specific",
5555
"slow: Tests that run multiple iterations (pass@k, repeated queries)",
56+
# --- Integration test suite (agents/*/tests/integration/) ---
57+
"integration: Deployment integration tests (build, deploy, health check, teardown)",
5658
]
5759

5860
[tool.setuptools.packages.find]

0 commit comments

Comments
 (0)