| from __future__ import annotations |
|
|
| import io |
| import json |
|
|
| from deberta_ime.ajimee import AjimeeArtifact |
| from deberta_ime.ajimee_cli import run |
| from deberta_ime.mozc import build_mozc_index |
|
|
|
|
| def test_ajimee_cli_writes_aggregate_boundary_audit(tmp_path) -> None: |
| dictionary_dir = tmp_path / "dictionary_oss" |
| dictionary_dir.mkdir() |
| (dictionary_dir / "dictionary00.txt").write_text( |
| "はし\t1\t1\t3500\t箸\nはし\t1\t1\t3800\t橋\n", |
| encoding="utf-8", |
| ) |
| index_path = tmp_path / "mozc.sqlite3" |
| build_mozc_index(dictionary_dir, index_path, source_revision="fixture") |
| items = ( |
| { |
| "index": "1", |
| "context_text": "川に架かる", |
| "input": "ハシ", |
| "expected_output": ["橋"], |
| "original_text": "川に架かる橋", |
| "splitted_input_for_limited_input_length": [], |
| }, |
| ) |
| artifact = AjimeeArtifact( |
| path=tmp_path / "items.json", |
| url="https://example.invalid/items.json", |
| revision="fixture-revision", |
| sha256="d" * 64, |
| size_bytes=100, |
| items=items, |
| ) |
| stdout = io.StringIO() |
|
|
| exit_code = run( |
| [ |
| "--index", |
| str(index_path), |
| "--output-dir", |
| str(tmp_path / "outputs"), |
| "--stem", |
| "audit_fixture", |
| ], |
| stdout=stdout, |
| artifact_loader=lambda data_dir: artifact, |
| ) |
|
|
| summary = json.loads(stdout.getvalue()) |
| report = json.loads((tmp_path / "outputs" / "audit_fixture.json").read_text("utf-8")) |
| assert exit_code == 0 |
| assert summary["ok"] is True |
| assert report["status"] == "LOCAL_INPUT_BOUNDARY_AUDIT" |
| assert report["audit"]["sequence_accuracy"] is None |
| assert (tmp_path / "outputs" / "audit_fixture.md").is_file() |
|
|