test: move area_cli tests into cli directory (#3842)

* test: move area_cli tests into cli directory

* test: include research CLI status in cli test move
This commit is contained in:
Alexandre Teixeira
2026-06-11 18:01:14 +01:00
committed by GitHub
parent 3e65326c3f
commit a79c0bd369
29 changed files with 7 additions and 6 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Regression: mcp CLI _serialize must not crash when env JSON is not an object.
`env_obj = json.loads(s.env)` can yield a list (e.g. env stored as "[1,2]").
`if redact_env and env_obj:` then called `env_obj.items()` -> AttributeError.
Guard with isinstance(dict).
"""
from types import SimpleNamespace
from tests.helpers.cli_loader import load_script
from tests.helpers.db_stubs import make_core_db_stub
def _srv(env):
return SimpleNamespace(id="s1", name="n", transport="stdio", command="c", args="[]",
env=env, url=None, is_enabled=1, oauth_config=None, created_at=None)
def test_serialize_handles_list_env(monkeypatch):
make_core_db_stub(monkeypatch, models=["McpServer"])
cli = load_script("odysseus-mcp")
out = cli._serialize(_srv("[1, 2]")) # JSON array, not object
assert out["id"] == "s1"
def test_serialize_redacts_dict_env(monkeypatch):
make_core_db_stub(monkeypatch, models=["McpServer"])
cli = load_script("odysseus-mcp")
out = cli._serialize(_srv('{"API_KEY": "secret"}'))
assert out["env"] == {"API_KEY": "***"}