← Files Aivana Incident IntelligenceARCHIVED FILE
tests/test_cli.py
843 Bytes · Oct 2, 2026 · 00:34 UTC
import json,subprocess,sys,tempfile,unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
class CliTests(unittest.TestCase):
def test_example(self):
with tempfile.TemporaryDirectory() as d:
out=Path(d)/'result.json';r=subprocess.run([sys.executable,str(ROOT/'scripts/run.py'),'--input',str(ROOT/'examples/input.json'),'--output',str(out)],capture_output=True);self.assertEqual(r.returncode,0,r.stderr);self.assertEqual(json.loads(out.read_text())['plugin'],ROOT.name)
def test_same_file_rejected(self):
with tempfile.TemporaryDirectory() as d:
p=Path(d)/'input.json';p.write_bytes((ROOT/'examples/input.json').read_bytes());r=subprocess.run([sys.executable,str(ROOT/'scripts/run.py'),'--input',str(p),'--output',str(p)],capture_output=True);self.assertEqual(r.returncode,2)
SHA-256: 97492a801de5ab3c778f7d0ae043c2783fca6b6477b58de15f4de6ae4c5bc154