-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_kind_gap.py
More file actions
173 lines (149 loc) · 5.69 KB
/
Copy pathtest_kind_gap.py
File metadata and controls
173 lines (149 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
class TestSpecOnlyKinds:
"""Verify spec-only kinds (operator, checkpoint, policy) fail with clear errors."""
def test_operator_kind_rejected(self, tmp_home, tmp_path, capsys):
"""kind: operator → explicit unsupported-kind error, no package copy."""
source_dir = tmp_path / "operator-cap"
source_dir.mkdir()
(source_dir / "capability.yaml").write_text("""\
kind: operator
name: operator-cap
version: 1.0.0
description: A test operator capability
""")
from capacium.commands.install import install_capability
result = install_capability(
"test/operator-cap@1.0.0",
source_dir=source_dir,
force=True,
yes=True,
no_lock=True,
skip_runtime_check=True,
)
assert result is False
out = capsys.readouterr().out
assert "unsupported" in out.lower()
assert "operator" in out
packages_dir = tmp_home / ".capacium" / "packages"
operator_pkg = packages_dir / "test" / "operator-cap"
assert not operator_pkg.exists()
def test_checkpoint_kind_rejected(self, tmp_home, tmp_path, capsys):
"""kind: checkpoint → explicit unsupported-kind error, no package copy."""
source_dir = tmp_path / "checkpoint-cap"
source_dir.mkdir()
(source_dir / "capability.yaml").write_text("""\
kind: checkpoint
name: checkpoint-cap
version: 1.0.0
description: A test checkpoint capability
""")
from capacium.commands.install import install_capability
result = install_capability(
"test/checkpoint-cap@1.0.0",
source_dir=source_dir,
force=True,
yes=True,
no_lock=True,
skip_runtime_check=True,
)
assert result is False
out = capsys.readouterr().out
assert "unsupported" in out.lower()
assert "checkpoint" in out
packages_dir = tmp_home / ".capacium" / "packages"
checkpoint_pkg = packages_dir / "test" / "checkpoint-cap"
assert not checkpoint_pkg.exists()
def test_policy_kind_rejected(self, tmp_home, tmp_path, capsys):
"""kind: policy → explicit unsupported-kind error, no package copy."""
source_dir = tmp_path / "policy-cap"
source_dir.mkdir()
(source_dir / "capability.yaml").write_text("""\
kind: policy
name: policy-cap
version: 1.0.0
description: A test policy capability
""")
from capacium.commands.install import install_capability
result = install_capability(
"test/policy-cap@1.0.0",
source_dir=source_dir,
force=True,
yes=True,
no_lock=True,
skip_runtime_check=True,
)
assert result is False
out = capsys.readouterr().out
assert "unsupported" in out.lower()
assert "policy" in out
packages_dir = tmp_home / ".capacium" / "packages"
policy_pkg = packages_dir / "test" / "policy-cap"
assert not policy_pkg.exists()
def test_unsupported_kind_error_message_is_actionable(self, tmp_home, tmp_path, capsys):
"""Error message tells user which kind is unsupported and what is supported."""
source_dir = tmp_path / "operator-cap"
source_dir.mkdir()
(source_dir / "capability.yaml").write_text("""\
kind: operator
name: operator-cap
version: 1.0.0
description: A test operator capability
""")
from capacium.commands.install import install_capability
result = install_capability(
"test/operator-cap@1.0.0",
source_dir=source_dir,
force=True,
yes=True,
no_lock=True,
skip_runtime_check=True,
)
assert result is False
out = capsys.readouterr().out
assert "operator" in out
for expected_kind in (
"skill", "bundle", "tool", "prompt", "template",
"workflow", "mcp-server", "connector-pack", "resource",
):
assert expected_kind in out, f"expected '{expected_kind}' in error output"
def test_no_registry_entry_written_on_unsupported_kind(self, tmp_home, tmp_path, capsys):
"""Neither registry entry nor client config is written for unsupported kind."""
source_dir = tmp_path / "operator-cap"
source_dir.mkdir()
(source_dir / "capability.yaml").write_text("""\
kind: operator
name: operator-cap
version: 1.0.0
description: A test operator capability
""")
from capacium.commands.install import install_capability
result = install_capability(
"test/operator-cap@1.0.0",
source_dir=source_dir,
force=True,
yes=True,
no_lock=True,
skip_runtime_check=True,
)
assert result is False
from capacium.registry import Registry
registry = Registry()
cap = registry.get_capability("test/operator-cap", "1.0.0")
assert cap is None
packages_dir = tmp_home / ".capacium" / "packages"
operator_pkg = packages_dir / "test" / "operator-cap" / "1.0.0"
assert not operator_pkg.exists()
def test_validate_manifest_rejects_spec_only_kinds(self, tmp_path):
"""Manifest validation catches spec-only kinds before install."""
manifest_yaml = tmp_path / "capability.yaml"
manifest_yaml.write_text("""\
kind: operator
name: operator-cap
version: 1.0.0
description: A test operator capability
""")
from capacium.manifest import Manifest
manifest = Manifest.load(manifest_yaml)
errors = manifest.validate()
assert len(errors) >= 1
assert any("unsupported" in e.lower() for e in errors)
assert any("operator" in e for e in errors)