|
4 | 4 | from pydantic import ValidationError |
5 | 5 |
|
6 | 6 | from kiln_ai.datamodel.project import Project |
7 | | -from kiln_ai.datamodel.skill import ( |
8 | | - Skill, |
9 | | - _parse_skill_md_body, |
10 | | -) |
| 7 | +from kiln_ai.datamodel.skill import Skill, _parse_skill_md_body |
11 | 8 |
|
12 | 9 |
|
13 | 10 | @pytest.fixture |
@@ -109,6 +106,14 @@ def test_body_raises_without_skill_md(mock_project): |
109 | 106 | skill.body() |
110 | 107 |
|
111 | 108 |
|
| 109 | +def test_skill_md_path_is_directory(mock_project): |
| 110 | + skill = make_skill(parent=mock_project) |
| 111 | + skill.save_to_file() |
| 112 | + skill.skill_md_path().mkdir() |
| 113 | + with pytest.raises(FileNotFoundError, match=r"SKILL\.md path is a folder"): |
| 114 | + skill.skill_md_raw() |
| 115 | + |
| 116 | + |
112 | 117 | def test_save_skill_md_empty_body_rejected(mock_project): |
113 | 118 | skill = make_skill(parent=mock_project) |
114 | 119 | skill.save_to_file() |
@@ -409,6 +414,12 @@ def test_binary_file_rejected(self, mock_project): |
409 | 414 | with pytest.raises(ValueError, match="not a readable text file"): |
410 | 415 | skill.read_reference("image.png") |
411 | 416 |
|
| 417 | + def test_read_reference_path_is_directory(self, mock_project): |
| 418 | + skill = save_skill_with_body(mock_project) |
| 419 | + (skill.references_dir() / "subdir").mkdir() |
| 420 | + with pytest.raises(ValueError, match="folder, not a file"): |
| 421 | + skill.read_reference("subdir") |
| 422 | + |
412 | 423 | def test_references_dir_requires_saved_skill(self): |
413 | 424 | skill = make_skill() |
414 | 425 | with pytest.raises(ValueError, match="Skill must be saved"): |
@@ -446,6 +457,12 @@ def test_asset_binary_file_rejected(self, mock_project): |
446 | 457 | with pytest.raises(ValueError, match="not a readable text file"): |
447 | 458 | skill.read_asset("photo.jpg") |
448 | 459 |
|
| 460 | + def test_read_asset_path_is_directory(self, mock_project): |
| 461 | + skill = save_skill_with_body(mock_project) |
| 462 | + (skill.assets_dir() / "data_dir").mkdir() |
| 463 | + with pytest.raises(ValueError, match="folder, not a file"): |
| 464 | + skill.read_asset("data_dir") |
| 465 | + |
449 | 466 | def test_assets_dir_requires_saved_skill(self): |
450 | 467 | skill = make_skill() |
451 | 468 | with pytest.raises(ValueError, match="Skill must be saved"): |
|
0 commit comments