test(runner): cover black-box group isolation
This commit is contained in:
@@ -56,3 +56,50 @@ def test_run_external_groups_orchestration(tmp_path, monkeypatch):
|
|||||||
out_file = outdir / "black_box" / "g1" / "cobol" / "output" / "ZAN04W01"
|
out_file = outdir / "black_box" / "g1" / "cobol" / "output" / "ZAN04W01"
|
||||||
assert out_file.read_bytes() == b"A0000001"
|
assert out_file.read_bytes() == b"A0000001"
|
||||||
assert "bb_g1" in calls[0][1]
|
assert "bb_g1" in calls[0][1]
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_external_groups_isolates_groups(tmp_path, monkeypatch):
|
||||||
|
fields_dict = [
|
||||||
|
{"name": "R01APPL-ID", "level": 3, "pic": "X(8)",
|
||||||
|
"pic_info": {"type": "alphanumeric", "digits": 0, "decimal": 0,
|
||||||
|
"length": 8, "signed": False}},
|
||||||
|
]
|
||||||
|
fd_fields = {"R01INNFIL": ["R01APPL-ID"], "W01OUTFIL": ["R01APPL-ID"]}
|
||||||
|
select_info = {"R01INNFIL": {"assign": "ZAN04R01"},
|
||||||
|
"W01OUTFIL": {"assign": "ZAN04W01",
|
||||||
|
"organization": "SEQUENTIAL"}}
|
||||||
|
open_dir = {"R01INNFIL": "INPUT", "W01OUTFIL": "OUTPUT"}
|
||||||
|
roles = {"R01APPL-ID": "input"}
|
||||||
|
field_to_fd = {"R01APPL-ID": "R01INNFIL"}
|
||||||
|
|
||||||
|
monkeypatch.setattr(runner, "compile_sub_modules", lambda *a, **k: [])
|
||||||
|
monkeypatch.setattr(runner, "compile_program",
|
||||||
|
lambda *a, **k: str(tmp_path / "P.exe"))
|
||||||
|
monkeypatch.setattr(runner, "_discover_java", lambda *a, **k: None)
|
||||||
|
|
||||||
|
def fake_run_group(group, exe_path, temp_dir, log_dir=None):
|
||||||
|
if "g1" in group.name:
|
||||||
|
Path(temp_dir, "ZAN04W01").write_bytes(b"ONLY_G1")
|
||||||
|
return runner.GroupResult(name=group.name, returncode=0, passed=True)
|
||||||
|
|
||||||
|
monkeypatch.setattr(runner, "run_group", fake_run_group)
|
||||||
|
|
||||||
|
groups = [
|
||||||
|
BlackBoxGroup(label="g1",
|
||||||
|
records=[{"R01APPL-ID": "A0000001"}],
|
||||||
|
term_types=["normal"]),
|
||||||
|
BlackBoxGroup(label="g2",
|
||||||
|
records=[{"R01APPL-ID": "A0000002"}],
|
||||||
|
term_types=["normal"]),
|
||||||
|
]
|
||||||
|
outdir = tmp_path / "out"
|
||||||
|
results, _ = runner.run_external_groups(
|
||||||
|
"P", str(outdir), str(tmp_path / "work"),
|
||||||
|
fields_dict, fd_fields, select_info, open_dir,
|
||||||
|
roles, field_to_fd, groups, source_dir=str(tmp_path / "src"),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert [r.name for r in results] == ["P_black_box_g1", "P_black_box_g2"]
|
||||||
|
assert (outdir / "black_box" / "g1" / "cobol" / "output" / "ZAN04W01").exists()
|
||||||
|
assert not (outdir / "black_box" / "g2" / "cobol" / "output" / "ZAN04W01").exists()
|
||||||
|
assert not (tmp_path / "work" / "bb_g2" / "ZAN04W01").exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user