42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""wiki_quorum.py CLI 통합 테스트."""
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
CLI = str(Path(__file__).with_name("wiki_quorum.py"))
|
|
|
|
|
|
def _adv(*pairs):
|
|
lines = "\n".join(f"finding: {fid} action: {act}" for fid, act in pairs)
|
|
return f"```wiki-verdict\nagent: wiki-adversarial-reviewer\n{lines}\n```"
|
|
|
|
|
|
class TestQuorumCLI(unittest.TestCase):
|
|
def _files(self, d, *texts):
|
|
paths = []
|
|
for i, t in enumerate(texts):
|
|
p = Path(d) / f"v{i}.md"
|
|
p.write_text(t)
|
|
paths.append(str(p))
|
|
return paths
|
|
|
|
def test_kill_exits_1(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
paths = self._files(d, _adv(("A", "REJECT")), _adv(("A", "REJECT")), _adv(("A", "KEEP")))
|
|
r = subprocess.run(["python3", CLI] + paths, capture_output=True, text=True)
|
|
self.assertEqual(r.returncode, 1)
|
|
self.assertIn("KILL", r.stdout)
|
|
|
|
def test_all_keep_exits_0(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
paths = self._files(d, _adv(("A", "KEEP")), _adv(("A", "KEEP")), _adv(("A", "KEEP")))
|
|
r = subprocess.run(["python3", CLI] + paths, capture_output=True, text=True)
|
|
self.assertEqual(r.returncode, 0)
|
|
self.assertIn("KEEP", r.stdout)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|