fix(tests): update project context CLI helper to unwrap JSON envelope format
CI / push-validation (pull_request) Successful in 23s
CI / helm (pull_request) Failing after 11m36s
CI / build (pull_request) Failing after 11m37s
CI / integration_tests (pull_request) Failing after 11m37s
CI / unit_tests (pull_request) Failing after 11m38s
CI / quality (pull_request) Failing after 11m39s
CI / security (pull_request) Failing after 11m40s
CI / typecheck (pull_request) Failing after 11m40s
CI / lint (pull_request) Failing after 11m40s
CI / docker (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
CI / push-validation (pull_request) Successful in 23s
CI / helm (pull_request) Failing after 11m36s
CI / build (pull_request) Failing after 11m37s
CI / integration_tests (pull_request) Failing after 11m37s
CI / unit_tests (pull_request) Failing after 11m38s
CI / quality (pull_request) Failing after 11m39s
CI / security (pull_request) Failing after 11m40s
CI / typecheck (pull_request) Failing after 11m40s
CI / lint (pull_request) Failing after 11m40s
CI / docker (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
This commit is contained in:
@@ -111,6 +111,19 @@ def _capturing_format_output(data: Any, format_type: str) -> str:
|
||||
_sys.stdout = old
|
||||
return ret or buf.getvalue().rstrip("\n")
|
||||
|
||||
def _unwrap_json_envelope(output: str) -> dict[str, Any]:
|
||||
"""Parse JSON output and unwrap the spec envelope if present.
|
||||
|
||||
``format_output`` wraps JSON in a spec-required envelope with keys
|
||||
``command``, ``status``, ``exit_code``, ``data``, ``timing``, and
|
||||
``messages``. This helper unwraps the envelope and returns the
|
||||
inner ``data`` dict. If the output is not an envelope (e.g. raw
|
||||
JSON without a ``data`` key), it is returned as-is.
|
||||
"""
|
||||
parsed = json.loads(output.strip())
|
||||
if isinstance(parsed, dict) and "data" in parsed:
|
||||
return parsed["data"] # type: ignore[return-value]
|
||||
return parsed # type: ignore[return-value]
|
||||
|
||||
def _run_cli_func(
|
||||
func: Any,
|
||||
@@ -237,7 +250,8 @@ def test_context_inspect_wired() -> None:
|
||||
if exit_code != 0:
|
||||
raise AssertionError(f"inspect failed with exit {exit_code}: {output}")
|
||||
|
||||
data = json.loads(output.strip())
|
||||
# format_output wraps JSON in a spec envelope; unwrap to get the payload
|
||||
data = _unwrap_json_envelope(output)
|
||||
if "tier_metrics" not in data:
|
||||
raise AssertionError(f"Missing tier_metrics in output: {data.keys()}")
|
||||
if "project_fragments" not in data:
|
||||
@@ -280,7 +294,8 @@ def test_context_simulate_wired() -> None:
|
||||
if exit_code != 0:
|
||||
raise AssertionError(f"simulate failed with exit {exit_code}: {output}")
|
||||
|
||||
data = json.loads(output.strip())
|
||||
# format_output wraps JSON in a spec envelope; unwrap to get the payload
|
||||
data = _unwrap_json_envelope(output)
|
||||
if "total_tokens" not in data:
|
||||
raise AssertionError(f"Missing total_tokens in output: {data.keys()}")
|
||||
if data["total_tokens"] <= 0:
|
||||
@@ -357,7 +372,8 @@ def test_context_show_acms_config() -> None:
|
||||
if exit_code != 0:
|
||||
raise AssertionError(f"show failed with exit {exit_code}: {output}")
|
||||
|
||||
data = json.loads(output.strip())
|
||||
# format_output wraps JSON in a spec envelope; unwrap to get the payload
|
||||
data = _unwrap_json_envelope(output)
|
||||
if "acms_config" not in data:
|
||||
raise AssertionError(f"Missing acms_config in output: {data.keys()}")
|
||||
if data["acms_config"]["hot_max_tokens"] != 5000:
|
||||
|
||||
Reference in New Issue
Block a user