fix(blackbox): don't pick up nested cobol/java input metadata

This commit is contained in:
2026-09-13 15:17:04 +08:00
parent 6d126ef6ab
commit 731a40418d
2 changed files with 25 additions and 1 deletions
+6 -1
View File
@@ -74,7 +74,12 @@ def _iter_group_files(path: Path) -> list[Path]:
files = sorted(p.glob('*_g*.json'))
if files:
return files
return sorted(p.rglob('*_g*.json'))
root = p / 'black_box' if (p / 'black_box').is_dir() else p
files = []
for sub in sorted(root.iterdir()):
if sub.is_dir():
files.extend(sorted(sub.glob('*_g*.json')))
return files
def _group_label(json_path: Path) -> str:
+19
View File
@@ -130,3 +130,22 @@ def test_load_groups_skips_non_dict_records():
})
groups = load_black_box_groups(tmp, fd_fields, select_info, data_fields)
assert groups[0].records[0]["R01APPL-ID"] == "F0000006"
def test_load_groups_ignores_nested_cobol_inputs():
fd_fields = {"R01INNFIL": ["R01APPL-ID"]}
select_info = {"R01INNFIL": {"assign": "ZAN04R01"}}
data_fields = [{"name": "R01APPL-ID", "pic": "X(8)"}]
with tempfile.TemporaryDirectory() as tmp:
d = Path(tmp) / "black_box" / "g1"
(d / "cobol" / "input").mkdir(parents=True)
(d / "ZAN04MAT_g1.json").write_text(json.dumps({
"program": "ZAN04MAT",
"records": [{"input": {"ZAN04R01": {"R01-APPL-ID": "A0000001"}}}],
}, ensure_ascii=False), encoding="utf-8")
(d / "cobol" / "input" / "ZAN04MAT_g1_R01INNFIL.json").write_text(
json.dumps([{"R01-APPL-ID": "A0000001"}], ensure_ascii=False),
encoding="utf-8")
groups = load_black_box_groups(tmp, fd_fields, select_info, data_fields)
assert len(groups) == 1
assert groups[0].records[0]["R01APPL-ID"] == "A0000001"