From eb65d3dc4f78ec59a06cec1c11b804e90723c3da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:13:29 +0000 Subject: [PATCH 1/2] Initial plan From 59db4978a5364a650afe96ab136bf1ec6838e164 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:16:57 +0000 Subject: [PATCH 2/2] test(mcp): add OSError handling test for install_mcp (PR #3) Co-authored-by: ychampion <68075205+ychampion@users.noreply.github.com> --- tests/test_codeclaw_cli_mcp.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_codeclaw_cli_mcp.py b/tests/test_codeclaw_cli_mcp.py index b491746..b540869 100644 --- a/tests/test_codeclaw_cli_mcp.py +++ b/tests/test_codeclaw_cli_mcp.py @@ -3,6 +3,8 @@ import sys from pathlib import Path +import pytest + from codeclaw import cli as codeclaw_cli from codeclaw import mcp_server @@ -215,3 +217,24 @@ def test_mcp_refresh_index_returns_meta(monkeypatch): assert payload["ok"] is True assert payload["meta"]["refresh_count"] == 1 assert payload["meta"]["session_count"] == 2 + + +def test_install_mcp_handles_read_oserror(monkeypatch, tmp_path): + monkeypatch.setattr(Path, "home", lambda: tmp_path) + config_path = tmp_path / ".claude" / "mcp.json" + config_path.parent.mkdir(parents=True, exist_ok=True) + config_path.write_text("{}", encoding="utf-8") + + original_read_text = Path.read_text + + def mock_read_text(self, *args, **kwargs): + if self == config_path: + raise OSError("Fake OS Error") + return original_read_text(self, *args, **kwargs) + + monkeypatch.setattr(Path, "read_text", mock_read_text) + + with pytest.raises(SystemExit) as excinfo: + mcp_server.install_mcp() + + assert excinfo.value.code == 1