fec4c09ee0
CI / test (push) Successful in 8s
doc_parser_skill: - New: verify_flowchart.py (flowchart validation) - Updated: LLM.py (multi-provider: DeepSeek + DashScope) - Updated: image_parser.py (logic tree support, external prompts) - Updated: SKILL.md, prompts/image_prompt.md conflict_detection_skill: - Updated: LLM.py (multi-provider sync) - Updated: detect_conflicts.py (logic tree text conversion) ir_generation_skill: - Replaced old scripts/LLM.py + ir_generator.py with standalone project - New: main.py, config.py, step1-3_*.py, ensemble_merge.py - New: prompts/, tests/ subdirectories tests: - New: acceptance/ test suite with schema validation - Fixed: conftest no longer globally skips non-acceptance tests - Updated: test_sample.py for new ir_generation structure Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
95 lines
3.1 KiB
Python
95 lines
3.1 KiB
Python
"""Minimal smoke tests for the document_analyzer pipeline."""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
|
|
import pytest
|
|
|
|
|
|
# -- Helpers ------------------------------------------------------------------
|
|
|
|
def _import_from_skill(skill_name, module_name):
|
|
"""Import a module from a skill's scripts directory."""
|
|
skill_dir = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)),
|
|
"skills", skill_name, "scripts"
|
|
)
|
|
if skill_dir not in sys.path:
|
|
sys.path.insert(0, skill_dir)
|
|
|
|
|
|
# -- WordParser tests (no LLM dependency) -------------------------------------
|
|
|
|
def test_import_word_parser():
|
|
"""word_parser module should be importable."""
|
|
_import_from_skill("doc_parser_skill", "word_parser")
|
|
import word_parser
|
|
assert hasattr(word_parser, "WordParser")
|
|
|
|
|
|
def test_import_image_parser():
|
|
"""image_parser module should be importable."""
|
|
_import_from_skill("doc_parser_skill", "image_parser")
|
|
import image_parser
|
|
assert hasattr(image_parser, "ImageParser")
|
|
|
|
|
|
def test_import_LLM():
|
|
"""LLM module should be importable (requires DASHSCOPE_API_KEY env var)."""
|
|
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
|
|
_import_from_skill("doc_parser_skill", "LLM")
|
|
import LLM
|
|
assert hasattr(LLM, "LLMClient")
|
|
|
|
|
|
# -- Conflict detection tests -------------------------------------------------
|
|
|
|
def test_import_detect_conflicts():
|
|
"""detect_conflicts module should be importable."""
|
|
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
|
|
_import_from_skill("conflict_detection_skill", "detect_conflicts")
|
|
import detect_conflicts
|
|
assert hasattr(detect_conflicts, "detect_conflicts")
|
|
|
|
|
|
# -- IR generation tests ------------------------------------------------------
|
|
|
|
def test_import_ir_main():
|
|
"""ir_generation main module should be importable (new project structure)."""
|
|
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
|
|
skill_dir = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)),
|
|
"skills", "ir_generation_skill"
|
|
)
|
|
if skill_dir not in sys.path:
|
|
sys.path.insert(0, skill_dir)
|
|
import main
|
|
assert hasattr(main, "main")
|
|
|
|
|
|
# -- Resolution application tests ---------------------------------------------
|
|
|
|
def test_import_apply_resolutions():
|
|
"""apply_resolutions module should be importable."""
|
|
_import_from_skill("resolution_application_skill", "apply_resolutions")
|
|
import apply_resolutions
|
|
assert hasattr(apply_resolutions, "apply_resolutions")
|
|
|
|
|
|
# -- JSON output validation ---------------------------------------------------
|
|
|
|
def test_sample_ir_json_is_valid():
|
|
"""The sample IR JSON file should be valid JSON."""
|
|
sample_path = os.path.join(
|
|
os.path.dirname(os.path.dirname(__file__)),
|
|
"skills", "ir_generation_skill",
|
|
"车机娱乐系统禁止功能文档_精简_updated.json"
|
|
)
|
|
if os.path.exists(sample_path):
|
|
with open(sample_path, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
assert isinstance(data, (dict, list))
|
|
else:
|
|
pytest.skip("Sample IR JSON not found")
|