31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from pathlib import Path
|
|
import json
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
FIXTURES = ROOT / "tests/fixtures/legacy"
|
|
|
|
class ShellRuntimeTests(unittest.TestCase):
|
|
def test_all_fixtures_keep_reviewed_counts(self):
|
|
expected = {
|
|
"windiagnostics-v1.json": ("complete", 1, 1),
|
|
"windiagnostics-v2-compact.json": ("partial", 0, 0),
|
|
"windiagnostics-v2-full.json": ("partial", 3, 1),
|
|
"windiagnostics-v2-partial.json": ("partial", 3, 1),
|
|
"windiagnostics-watchlist.json": ("partial", 11, 7),
|
|
}
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
for name, wanted in expected.items():
|
|
output = Path(directory) / name
|
|
result = subprocess.run(["bash", ROOT / "analyse.sh", FIXTURES / name,
|
|
"--evidence-root", FIXTURES, "--output", output,
|
|
"--reference-time", "2026-09-15T12:00:00Z", "--producer-version", "test"],
|
|
text=True, capture_output=True)
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
doc = json.loads(output.read_text())
|
|
self.assertEqual((doc["collection"]["status"], len(doc["observations"]), len(doc["findings"])), wanted)
|
|
|
|
if __name__ == "__main__": unittest.main()
|