✨ bypass + correctif

This commit is contained in:
Orionis committed 2026-11-16 22:43:11 +01:00
1 parent 1cbbf7aa3c
commit 902529a4ea
9 files changed
+59 -7

No files matched your search

+23
View File
@@ -2,6 +2,7 @@ import json
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from scalper import pipeline
from scalper.exporter import export_chapter, slugify
@@ -30,6 +31,28 @@ class TestPipeline(unittest.TestCase):
res = pipeline.run_pipeline("demo", "demo-1", "fr", out_root=tmp, mock_llm=True)
self.assertTrue(any(c.get("skipped") for c in res["chapters"]))
def test_qa_failure_blocks_export_without_force(self):
fake = {"score": 10, "pass": False, "issues": [{"type": "x", "critical": True}]}
with tempfile.TemporaryDirectory() as tmp:
with mock.patch("scalper.pipeline.qa_chapter", return_value=fake):
res = pipeline.run_pipeline("demo", "demo-1", "fr", out_root=tmp, mock_llm=True, max_chapters=1)
self.assertEqual(res["chapters"][0]["status"], "qa_failed")
raw1 = Path(tmp) / "raw" / "demo" / "demo-1" / "demo-1-ch1"
self.assertFalse((raw1 / "export").exists())
def test_force_exports_despite_qa_failure(self):
fake = {"score": 10, "pass": False, "issues": [{"type": "x", "critical": True}]}
with tempfile.TemporaryDirectory() as tmp:
with mock.patch("scalper.pipeline.qa_chapter", return_value=fake):
res = pipeline.run_pipeline("demo", "demo-1", "fr", out_root=tmp, mock_llm=True, max_chapters=1, force=True)
self.assertEqual(res["status"], "done")
ch = res["chapters"][0]
self.assertEqual(ch["status"], "ok")
self.assertTrue(ch.get("forced"))
self.assertFalse(ch["qa"]["pass"])
raw1 = Path(tmp) / "raw" / "demo" / "demo-1" / "demo-1-ch1"
self.assertTrue(list((raw1 / "export").glob("*.md")))
class TestExporter(unittest.TestCase):
def test_exports(self):
+11
View File
@@ -5,6 +5,7 @@ import unittest
import urllib.error
import urllib.request
from http.server import ThreadingHTTPServer
from unittest import mock
from scalper.server import Handler
@@ -63,6 +64,16 @@ class TestServer(unittest.TestCase):
status, body = self._post("/run", {"source": "demo"})
self.assertEqual(status, 400)
def test_run_force_bypasses_qa_gate(self):
fake = {"score": 10, "pass": False, "issues": [{"type": "x", "critical": True}]}
with tempfile.TemporaryDirectory() as tmp:
with mock.patch("scalper.pipeline.qa_chapter", return_value=fake):
status, body = self._post("/run", {"source": "demo", "series": "demo-1", "lang": "fr", "mock_llm": True, "out": tmp, "max_chapters": 1, "force": True})
self.assertEqual(status, 200)
self.assertEqual(body["status"], "done")
self.assertEqual(body["chapters"][0]["status"], "ok")
self.assertTrue(body["chapters"][0].get("forced"))
if __name__ == "__main__":
unittest.main()