Skip to content

The agent that grows with you

test(skills): trim occupied-directory create suite to two invariants

kshitijk4poorc383a9fc421c
diff --git a/tests/tools/test_skill_create_occupied_directory.py b/tests/tools/test_skill_create_occupied_directory.py
index 2c05a394be9..6121aee9995 100644
--- a/tests/tools/test_skill_create_occupied_directory.py
+++ b/tests/tools/test_skill_create_occupied_directory.py
@@ -33,52 +33,20 @@ def test_occupied_directory_is_preserved_when_scan_blocks(tmp_path):
data.write_bytes(b"keep me")
result = _create_skill("new-skill", VALID_CONTENT)
- assert result["success"] is False
- assert data.read_bytes() == b"keep me"
- assert target.is_dir()
- assert not (target / "SKILL.md").exists()
-
-
-def test_occupied_directory_is_preserved_when_scan_does_not_block(tmp_path):
- with _skill_dir(tmp_path), patch("tools.skill_manager_tool._security_scan_skill", return_value=None):
- target = tmp_path / "new-skill"
- target.mkdir()
- data = target / "data.bin"
- data.write_bytes(b"keep me")
- result = _create_skill("new-skill", VALID_CONTENT)
+ # An EMPTY pre-existing directory (leftover of an earlier failed create) is a valid target,
+ # but a blocked scan removes only what create wrote and leaves the directory in place.
+ empty = tmp_path / "empty-skill"
+ empty.mkdir()
+ empty_result = _create_skill("empty-skill", VALID_CONTENT)
assert result["success"] is False
assert data.read_bytes() == b"keep me"
assert target.is_dir()
assert not (target / "SKILL.md").exists()
-
-def test_preexisting_skill_file_is_preserved_when_index_does_not_find_it(tmp_path):
- with _skill_dir(tmp_path), patch("tools.skill_manager_tool._find_skill", return_value=None):
- target = tmp_path / "new-skill"
- target.mkdir()
- skill_md = target / "SKILL.md"
- skill_md.write_bytes(b"original")
- result = _create_skill("new-skill", VALID_CONTENT)
-
- assert result["success"] is False
- assert skill_md.read_bytes() == b"original"
-
-
-def test_fresh_directory_is_removed_when_scan_blocks(tmp_path):
- with _skill_dir(tmp_path), patch("tools.skill_manager_tool._security_scan_skill", return_value="blocked"):
- result = _create_skill("new-skill", VALID_CONTENT)
-
- assert result["success"] is False
- assert not (tmp_path / "new-skill").exists()
-
-
-def test_fresh_directory_is_created_when_scan_does_not_block(tmp_path):
- with _skill_dir(tmp_path), patch("tools.skill_manager_tool._security_scan_skill", return_value=None):
- result = _create_skill("new-skill", VALID_CONTENT)
-
- assert result["success"] is True
- assert (tmp_path / "new-skill" / "SKILL.md").exists()
+ assert empty_result["success"] is False
+ assert empty.is_dir()
+ assert not any(empty.iterdir())
def test_category_directory_collision_is_refused(tmp_path):
@@ -89,16 +57,14 @@ def test_category_directory_collision_is_refused(tmp_path):
nested.write_bytes(b"nested")
result = _create_skill("category", VALID_CONTENT)
+ # Empty pre-existing directory + clean scan: create succeeds (retry after a leftover works).
+ empty = tmp_path / "empty-skill"
+ empty.mkdir()
+ empty_result = _create_skill("empty-skill", VALID_CONTENT)
+
assert result["success"] is False
assert nested.read_bytes() == b"nested"
assert not (category / "SKILL.md").exists()
-
-def test_file_occupying_skill_path_is_not_deleted(tmp_path):
- with _skill_dir(tmp_path):
- target = tmp_path / "new-skill"
- target.write_bytes(b"do not delete")
- result = _create_skill("new-skill", VALID_CONTENT)
-
- assert result["success"] is False
- assert target.read_bytes() == b"do not delete"
+ assert empty_result["success"] is True
+ assert (empty / "SKILL.md").exists()