mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-26 09:15:08 +00:00
Lint: - Remove unused imports (click, pytest, json) - Replace try-except-pass with logging (S110) - Fix unprotected zipfile.extractall (S202) Security: - Path traversal: startswith → is_relative_to for tar extraction - Add path traversal protection to ZIP extraction via _safe_extract_zip - Both cache.py and CLI main.py hardened Type checker: - Fix import path: crewai.events.event_bus (not crewai_event_bus) - Remove unused type: ignore comments - Fix type mismatches in set_skills() variable types Code quality: - Fix f-string interpolation in SkillNotCachedError - Use ValidationError instead of Exception in test
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Tests for the version field added to SkillFrontmatter."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from crewai.skills.models import SkillFrontmatter
|
|
|
|
|
|
class TestSkillFrontmatterVersion:
|
|
def test_version_defaults_to_none(self) -> None:
|
|
fm = SkillFrontmatter(name="my-skill", description="A skill.")
|
|
assert fm.version is None
|
|
|
|
def test_version_can_be_set(self) -> None:
|
|
fm = SkillFrontmatter(name="my-skill", description="A skill.", version="1.2.3")
|
|
assert fm.version == "1.2.3"
|
|
|
|
def test_existing_frontmatter_without_version_still_valid(self) -> None:
|
|
"""Backward compat: existing SKILL.md files without version must still parse."""
|
|
fm = SkillFrontmatter(name="old-skill", description="Old skill without version.")
|
|
assert fm.version is None
|
|
|
|
def test_version_is_optional_string(self) -> None:
|
|
fm = SkillFrontmatter(name="my-skill", description="Desc.", version=None)
|
|
assert fm.version is None
|
|
|
|
def test_frontmatter_is_frozen(self) -> None:
|
|
fm = SkillFrontmatter(name="my-skill", description="A skill.", version="1.0.0")
|
|
with pytest.raises(ValidationError):
|
|
fm.version = "2.0.0" # type: ignore[misc]
|