|
| 1 | +import os |
1 | 2 | from pathlib import Path |
2 | 3 |
|
| 4 | +import pytest |
| 5 | + |
3 | 6 | from unity_docs_mcp.bake.extract_manual import extract_manual |
4 | 7 | from unity_docs_mcp.bake.extract_scriptref import extract_scriptref |
5 | 8 | from unity_docs_mcp.bake.html_to_md import HtmlToTextOptions |
6 | 9 |
|
| 10 | +FIXTURES_DIR = Path(__file__).parent / "fixtures" |
| 11 | +REAL_DOCS_ROOT = Path("data/unity/6000.3/raw/UnityDocumentation/Documentation/en") |
| 12 | +ENABLE_E2E = os.environ.get("UNITYDOCS_E2E") == "1" |
| 13 | + |
7 | 14 |
|
8 | 15 | def test_manual_extraction_smoke(): |
9 | | - sample = Path("data/unity/6000.3/raw/UnityDocumentation/Documentation/en/Manual/index.html") |
10 | | - assert sample.exists(), "Manual index missing; ensure Unity docs present" |
| 16 | + sample = FIXTURES_DIR / "manual_index.html" |
| 17 | + assert sample.exists(), "Fixture missing" |
11 | 18 | res = extract_manual(sample, HtmlToTextOptions(), drop_sections_list=[]) |
| 19 | + assert "Create and run a job" in res["title"] |
12 | 20 | assert len(res["text_md"]) > 200 |
13 | 21 |
|
14 | 22 |
|
15 | 23 | def test_scriptref_extraction_smoke(): |
16 | | - sample = Path( |
17 | | - "data/unity/6000.3/raw/UnityDocumentation/Documentation/en/ScriptReference/Unity.Jobs.IJobParallelFor.html" |
18 | | - ) |
19 | | - assert sample.exists(), "ScriptReference sample missing; ensure Unity docs present" |
| 24 | + sample = FIXTURES_DIR / "scriptref_iJobParallelFor.html" |
| 25 | + assert sample.exists(), "Fixture missing" |
| 26 | + res = extract_scriptref(sample, HtmlToTextOptions()) |
| 27 | + assert "IJobParallelFor" in res["title"] |
| 28 | + assert len(res["text_md"]) > 200 |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.skipif(not ENABLE_E2E, reason="set UNITYDOCS_E2E=1 to run real-doc integration tests") |
| 32 | +def test_manual_extraction_real_docs(): |
| 33 | + sample = REAL_DOCS_ROOT / "Manual/index.html" |
| 34 | + if not sample.exists(): |
| 35 | + pytest.skip("Manual docs not present under data/unity/6000.3/raw") |
| 36 | + res = extract_manual(sample, HtmlToTextOptions(), drop_sections_list=[]) |
| 37 | + assert len(res["text_md"]) > 200 |
| 38 | + |
| 39 | + |
| 40 | +@pytest.mark.skipif(not ENABLE_E2E, reason="set UNITYDOCS_E2E=1 to run real-doc integration tests") |
| 41 | +def test_scriptref_extraction_real_docs(): |
| 42 | + sample = REAL_DOCS_ROOT / "ScriptReference/Unity.Jobs.IJobParallelFor.html" |
| 43 | + if not sample.exists(): |
| 44 | + pytest.skip("ScriptReference docs not present under data/unity/6000.3/raw") |
20 | 45 | res = extract_scriptref(sample, HtmlToTextOptions()) |
21 | 46 | assert "IJobParallelFor" in res["title"] |
22 | 47 | assert len(res["text_md"]) > 200 |
0 commit comments