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
2 changes: 1 addition & 1 deletion src/apm_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def set_copilot_cowork_skills_dir(path: str) -> None:
"""
if not path or not path.strip():
raise ValueError("Path cannot be empty")
expanded = os.path.expanduser(path)
expanded = os.path.normpath(os.path.expanduser(path))
if not os.path.isabs(expanded):
raise ValueError(f"Path must be absolute: {expanded}")
update_config({"copilot_cowork_skills_dir": expanded})
Expand Down
66 changes: 45 additions & 21 deletions tests/unit/integration/test_copilot_cowork_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ def test_macos_single_tenant_returns_skills_dir(
cloud_dir = tmp_path / "Library" / "CloudStorage"
tenant_dir = cloud_dir / "OneDrive - Tenant"
tenant_dir.mkdir(parents=True)
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
result = resolve_copilot_cowork_skills_dir()
expected = tenant_dir / "Documents" / "Cowork" / "skills"
Expand All @@ -87,9 +90,12 @@ def test_macos_zero_tenant_returns_none(
cloud_dir = tmp_path / "Library" / "CloudStorage"
cloud_dir.mkdir(parents=True)
# No OneDrive dirs
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
result = resolve_copilot_cowork_skills_dir()
assert result is None
Expand All @@ -99,9 +105,12 @@ def test_macos_no_cloud_storage_dir_returns_none(
) -> None:
monkeypatch.delenv("APM_COPILOT_COWORK_SKILLS_DIR", raising=False)
# No Library/CloudStorage at all
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
result = resolve_copilot_cowork_skills_dir()
assert result is None
Expand All @@ -113,9 +122,12 @@ def test_macos_multi_tenant_raises_cowork_resolution_error(
cloud_dir = tmp_path / "Library" / "CloudStorage"
(cloud_dir / "OneDrive - TenantA").mkdir(parents=True)
(cloud_dir / "OneDrive - TenantB").mkdir(parents=True)
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
with pytest.raises(CoworkResolutionError):
resolve_copilot_cowork_skills_dir()
Expand All @@ -127,9 +139,12 @@ def test_multi_tenant_error_message_lists_candidates(
cloud_dir = tmp_path / "Library" / "CloudStorage"
(cloud_dir / "OneDrive - TenantA").mkdir(parents=True)
(cloud_dir / "OneDrive - TenantB").mkdir(parents=True)
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
with pytest.raises(CoworkResolutionError) as exc_info:
resolve_copilot_cowork_skills_dir()
Expand All @@ -144,9 +159,12 @@ def test_multi_tenant_error_message_hint_contains_env_var_name(
cloud_dir = tmp_path / "Library" / "CloudStorage"
(cloud_dir / "OneDrive - TenantA").mkdir(parents=True)
(cloud_dir / "OneDrive - TenantB").mkdir(parents=True)
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
with pytest.raises(CoworkResolutionError) as exc_info:
resolve_copilot_cowork_skills_dir()
Expand All @@ -165,9 +183,12 @@ def test_linux_no_env_returns_none(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.delenv("APM_COPILOT_COWORK_SKILLS_DIR", raising=False)
with patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
with (
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "linux"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
),
):
result = resolve_copilot_cowork_skills_dir()
assert result is None
Expand All @@ -186,6 +207,7 @@ def test_config_beats_macos_auto_detect(
(cloud / "OneDrive - Tenant").mkdir(parents=True)
with (
patch("apm_cli.config.get_copilot_cowork_skills_dir", return_value="/config/skills"),
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
Expand Down Expand Up @@ -215,6 +237,7 @@ def test_auto_detect_used_when_both_env_and_config_absent(
tenant.mkdir(parents=True)
with (
patch("apm_cli.config.get_copilot_cowork_skills_dir", return_value=None),
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
Expand Down Expand Up @@ -243,6 +266,7 @@ def test_config_none_falls_through_cleanly_to_next_branch(
# No CloudStorage directory -- auto-detect returns None.
with (
patch("apm_cli.config.get_copilot_cowork_skills_dir", return_value=None),
patch("apm_cli.integration.copilot_cowork_paths.sys.platform", "darwin"),
patch(
"apm_cli.integration.copilot_cowork_paths.Path.home",
return_value=tmp_path,
Expand Down
Loading