forked from ARPAHLS/skillware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_skill.py
More file actions
51 lines (39 loc) · 1.77 KB
/
Copy pathtest_skill.py
File metadata and controls
51 lines (39 loc) · 1.77 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
import pytest
import yaml
import os
from .skill import MyAwesomeSkill
@pytest.fixture
def skill():
"""Fixture to initialize the skill class."""
return MyAwesomeSkill()
@pytest.fixture
def manifest():
"""Fixture to load the manifest.yaml for validation."""
manifest_path = os.path.join(os.path.dirname(__file__), "manifest.yaml")
with open(manifest_path, "r", encoding="utf-8") as f:
return yaml.safe_load(f)
def test_skill_manifest_consistency(skill, manifest):
"""Verify the skill's internal manifest matches the manifest.yaml file basics."""
skill_manifest = skill.manifest
assert skill_manifest["name"] == manifest["name"]
assert skill_manifest["version"] == manifest["version"]
def test_skill_execution(skill, manifest):
"""Test the skill execution and validate output schema."""
# 1. Prepare dummy input
params = {"param1": "test-value"}
# 2. Execute
result = skill.execute(params)
# 3. Validate result is a dictionary (JSON serializable)
assert isinstance(result, dict), "Execution result must be a dictionary"
# 4. Validate against 'outputs' defined in manifest.yaml
expected_outputs = manifest.get("outputs", {})
for key, spec in expected_outputs.items():
assert key in result, f"Missing expected output key: '{key}'"
# Optional: Basic type checking based on manifest
expected_type = spec.get("type")
if expected_type == "string":
assert isinstance(result[key], str), f"Output '{key}' should be a string"
elif expected_type == "integer":
assert isinstance(result[key], int), f"Output '{key}' should be an integer"
elif expected_type == "boolean":
assert isinstance(result[key], bool), f"Output '{key}' should be a boolean"