Files
wehub-resource-sync 2cab53bc94
Test Vector Database Adaptors / Test MCP Vector DB Tools (push) Has been cancelled
Tests / Code Quality (Ruff & Mypy) (push) Has been cancelled
Tests / Fast Unit Tests (parallel) (macos-latest, 3.11) (push) Has been cancelled
Tests / Fast Unit Tests (parallel) (macos-latest, 3.12) (push) Has been cancelled
Tests / Tests (push) Has been cancelled
Docker Publish / Build and Push Docker Images (map[description:Skill Seekers CLI - Convert documentation to AI skills dockerfile:Dockerfile name:skill-seekers]) (push) Has been cancelled
Docker Publish / Build and Push Docker Images (map[description:Skill Seekers MCP Server - 25 tools for AI assistants dockerfile:Dockerfile.mcp name:skill-seekers-mcp]) (push) Has been cancelled
Docker Publish / Test Docker Images (push) Has been cancelled
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.10) (push) Has been cancelled
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / Fast Unit Tests (parallel) (ubuntu-latest, 3.12) (push) Has been cancelled
Tests / Serial / Integration / E2E Tests (push) Has been cancelled
Tests / MCP Server Tests (push) Has been cancelled
Test Vector Database Adaptors / Test chroma Adaptor (push) Has been cancelled
Test Vector Database Adaptors / Test faiss Adaptor (push) Has been cancelled
Test Vector Database Adaptors / Test qdrant Adaptor (push) Has been cancelled
Test Vector Database Adaptors / Test weaviate Adaptor (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:46:28 +08:00

77 lines
3.4 KiB
Python

from dataclasses import asdict
from skill_seekers.cli.conflict_detector import ConflictDetector, Conflict
class TestConflictDetectorEdgeCases:
"""Edge case tests for ConflictDetector when docs and code data diverge."""
def test_detector_with_empty_docs_data(self):
"""When docs_data is empty dict, detector should still initialize without error."""
detector = ConflictDetector(docs_data={}, github_data={"apis": {}})
assert detector is not None
assert detector.docs_apis == {}
assert detector.code_apis == {}
def test_detector_with_empty_code_data(self):
"""When github_data is empty dict, detector should still initialize without error."""
detector = ConflictDetector(docs_data={"apis": {}}, github_data={})
assert detector is not None
assert detector.docs_apis == {}
assert detector.code_apis == {}
def test_detector_with_both_empty(self):
"""When both data sources are empty, detector should still initialize."""
detector = ConflictDetector(docs_data={}, github_data={})
assert detector is not None
conflicts = detector.detect_all_conflicts()
assert conflicts == []
def test_apis_with_non_dict_structure(self):
"""When apis are not dicts (e.g., list), extraction should not crash."""
detector = ConflictDetector(
docs_data={"apis": [{"name": "test"}]}, # wrong structure
github_data={"apis": {"test_api": {}}},
)
assert detector.docs_apis == {} # should gracefully skip non-dict entries
def test_conflict_dataclass_all_fields_none(self):
"""Conflict dataclass should be instantiable with all None optional fields."""
conflict = Conflict(type="missing_in_code", severity="high", api_name="test_api")
assert conflict.type == "missing_in_code"
assert conflict.severity == "high"
assert conflict.api_name == "test_api"
assert conflict.docs_info is None
assert conflict.code_info is None
assert conflict.difference is None
assert conflict.suggestion is None
def test_conflict_asdict_with_all_fields(self):
"""dataclasses.asdict(conflict) should produce a full, deep-copied mapping.
Mirrors the production serialization path (see ConflictDetector, which
emits ``asdict(c)`` for each conflict), rather than the shallow
``__dict__`` attribute view.
"""
conflict = Conflict(
type="signature_mismatch",
severity="medium",
api_name="my_api",
docs_info={"params": ["a", "b"]},
code_info={"params": ["a", "b", "c"]},
difference="code has extra param c",
suggestion="add param c to docs",
)
d = asdict(conflict)
assert d["type"] == "signature_mismatch"
assert d["severity"] == "medium"
assert d["api_name"] == "my_api"
assert d["docs_info"] == {"params": ["a", "b"]}
assert d["code_info"] == {"params": ["a", "b", "c"]}
assert d["difference"] == "code has extra param c"
assert d["suggestion"] == "add param c to docs"
# asdict() recursively copies nested containers (unlike __dict__), so
# mutating the result must not leak back into the original instance.
d["docs_info"]["params"].append("mutated")
assert conflict.docs_info == {"params": ["a", "b"]}