45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from pathlib import Path
|
|
|
|
from applepy.context import RunContext
|
|
from applepy.findings import Finding, Severity
|
|
from applepy.registry import CheckRegistry
|
|
from applepy.runner import run_phase
|
|
|
|
|
|
def test_run_phase_parallel_returns_all_findings(tmp_path: Path) -> None:
|
|
r = CheckRegistry()
|
|
|
|
def check_a(ctx: RunContext) -> list[Finding]:
|
|
return [
|
|
Finding(
|
|
id="p-a",
|
|
title="A",
|
|
category="T",
|
|
severity=Severity.INFORMATIONAL,
|
|
description="d",
|
|
evidence="e",
|
|
worksheet="S",
|
|
)
|
|
]
|
|
|
|
def check_b(ctx: RunContext) -> list[Finding]:
|
|
return [
|
|
Finding(
|
|
id="p-b",
|
|
title="B",
|
|
category="T",
|
|
severity=Severity.INFORMATIONAL,
|
|
description="d",
|
|
evidence="e",
|
|
worksheet="S",
|
|
)
|
|
]
|
|
|
|
r.register("a", check_a, phases=("unprivileged",))
|
|
r.register("b", check_b, phases=("unprivileged",))
|
|
base = RunContext(home=tmp_path, output_dir=tmp_path, phase="unprivileged")
|
|
seq = run_phase(r, "unprivileged", base, parallel=False)
|
|
par = run_phase(r, "unprivileged", base, parallel=True)
|
|
assert {f.id for f in seq} == {"p-a", "p-b"}
|
|
assert {f.id for f in par} == {"p-a", "p-b"}
|