Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tests/cli/test_cli_harness_open_source_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ def test_harness_dockerfile_uses_accelerated_source_with_official_fallback() ->
in cli_harness._DOCKERFILE
)
assert "https://github.com/volcengine/veadk-python.git" in cli_harness._DOCKERFILE
# The harness advertises `runtime: codex` in harness.yaml and honours a
# per-request runtime override, so the image must carry the codex extra or
# every such request fails with an ImportError on an already-deployed
# runtime.
assert '"./src[harness,codex]"' in cli_harness._DOCKERFILE
# The generated image is the shared HarnessApp runtime: it must carry the
# optional backend extras used by request-level resources, plus codex for
# runtime overrides.
assert '"./src[extensions,database,harness,codex]"' in cli_harness._DOCKERFILE
old_package_path = "packages/" + "agentkit" + "-harness-python"
assert old_package_path not in cli_harness._DOCKERFILE

Expand Down
35 changes: 30 additions & 5 deletions tests/cli/test_frontend_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

from __future__ import annotations

import importlib
import json
import sys
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from types import SimpleNamespace
from typing import cast
Expand Down Expand Up @@ -55,14 +59,33 @@ def _write_agent_app(tmp_path: Path, app_name: str, source: str) -> None:
(app_dir / "agent.py").write_text(source, encoding="utf-8")


def _build_adk_web_client(tmp_path: Path) -> TestClient:
_MISSING = object()


@contextmanager
def _build_adk_web_client(tmp_path: Path) -> Iterator[TestClient]:
from google.adk.cli.fast_api import get_fast_api_app

from veadk.utils.patches import patch_adk_build_graph_serialization

original_sys_path = list(sys.path)
app_names = [path.name for path in tmp_path.iterdir() if path.is_dir()]
module_names = {name for name in app_names}
module_names.update(f"{name}.agent" for name in app_names)
original_modules = {name: sys.modules.get(name, _MISSING) for name in module_names}
patch_adk_build_graph_serialization()
app = get_fast_api_app(agents_dir=str(tmp_path), web=True)
return TestClient(app)
try:
app = get_fast_api_app(agents_dir=str(tmp_path), web=True)
with TestClient(app) as client:
yield client
finally:
sys.path[:] = original_sys_path
for name, module in original_modules.items():
if module is _MISSING:
sys.modules.pop(name, None)
else:
sys.modules[name] = module
importlib.invalidate_caches()


def test_session_trace_route_returns_json_spans() -> None:
Expand Down Expand Up @@ -177,7 +200,8 @@ def hello() -> str:
""",
)

response = _build_adk_web_client(tmp_path).get("/dev/apps/demo_agent/build_graph")
with _build_adk_web_client(tmp_path) as client:
response = client.get("/dev/apps/demo_agent/build_graph")

assert response.status_code == 200
payload = response.json()
Expand Down Expand Up @@ -216,7 +240,8 @@ def test_build_graph_serializes_nested_veadk_agent_models(tmp_path: Path) -> Non
""",
)

response = _build_adk_web_client(tmp_path).get("/dev/apps/nested_agent/build_graph")
with _build_adk_web_client(tmp_path) as client:
response = client.get("/dev/apps/nested_agent/build_graph")

assert response.status_code == 200
payload = response.json()
Expand Down
Loading
Loading