add choose skills function

This commit is contained in:
kuangji
2026-05-19 13:22:25 +08:00
parent 1e20f84257
commit 6661f3e361
6 changed files with 118 additions and 10 deletions

View File

@@ -4,7 +4,7 @@ from app.skill_loader import load_skill_catalog
def test_load_skill_catalog_reads_index_and_skill_files() -> None:
skills = load_skill_catalog(Path("GJB438C-2021_prd_skills"))
skills = load_skill_catalog(Path("skills") / "GJB438C-2021_prd_skills")
assert len(skills) >= 30
skill_names = {skill.slug for skill in skills}
@@ -12,3 +12,10 @@ def test_load_skill_catalog_reads_index_and_skill_files() -> None:
target = next(skill for skill in skills if skill.slug == "gjb438c-software-requirements-spec-structure")
assert "软件需求规格说明" in target.content
assert target.path.name == "SKILL.md"
def test_load_skill_catalog_reads_gjb438b_collection() -> None:
skills = load_skill_catalog(Path("skills") / "GJB438B-2009_prd_skills")
assert len(skills) > 0
assert any(skill.slug.startswith("gjb438b-") for skill in skills)

View File

@@ -2,7 +2,7 @@ from pathlib import Path
from docx import Document
from app.main import OUTPUT_DIR, ROOT_DIR, analyze_saved_docx
from app.main import OUTPUT_DIR, ROOT_DIR, analyze_saved_docx, app
def test_index_template_contains_upload_ui() -> None:
@@ -14,9 +14,11 @@ def test_index_template_contains_upload_ui() -> None:
assert "analysis-progress" in html
assert "analysis-status" in html
assert "下载 Markdown 报告" in html
assert "<!-- <a id=\"download-docx\"" in html
assert "download-md" in js
assert "pollTask" in js
assert "skill_collection" in html
assert "预留后续版本:单个技能集合内的 skill 筛选功能" in html
assert not any(route.path == "/skills" for route in app.routes)
def test_analyze_saved_docx_reports_progress(tmp_path: Path) -> None:
@@ -53,3 +55,20 @@ def test_analyze_saved_docx_creates_downloadable_report(tmp_path: Path) -> None:
assert "docx" not in payload["downloads"]
assert payload["downloads"]["markdown"].endswith(".md")
assert (OUTPUT_DIR / Path(payload["downloads"]["markdown"]).name).exists()
def test_analyze_saved_docx_uses_selected_collection(tmp_path: Path) -> None:
docx_path = tmp_path / "upload.docx"
document = Document()
document.add_heading("软件需求规格说明", level=1)
document.add_paragraph("能力需求、接口需求、合格性规定。")
document.save(docx_path)
payload = analyze_saved_docx(
docx_path,
provider="deepseek",
use_model=False,
skill_collection="GJB438B-2009_prd_skills",
)
assert payload["matched_skills"]