From 337933cb62f0ebb4774fbc14e32b9b67b2d97067 Mon Sep 17 00:00:00 2001 From: maxime Date: Mon, 9 Nov 2026 09:14:04 +0100 Subject: [PATCH] =?UTF-8?q?Simulation=20sans=20liste=20blanche=20:=20toute?= =?UTF-8?q?s=20les=20conversations=20(la=20liste=20ne=20s'impose=20qu'en?= =?UTF-8?q?=20=C3=A9criture)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- support_diagnostic/run.py | 6 ++++-- tests/test_run.py | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/support_diagnostic/run.py b/support_diagnostic/run.py index 932bc35..20bc1c1 100644 --- a/support_diagnostic/run.py +++ b/support_diagnostic/run.py @@ -29,7 +29,7 @@ class Config: cle: str secret: str ecrire: bool - autorisees: set[str] | None # None : toutes (« * ») ; vide (simulation sans liste) : aucune + autorisees: set[str] | None # None : toutes (« * », ou simulation sans liste) plafond: int conversation: str # "" : toutes les éligibles ; sinon celle-ci, forcée, même sans tri:diagnostic donnees: Path @@ -43,8 +43,10 @@ class Config: ecrire = env.get("DRY_RUN", "true").strip() == "false" liste = env.get("ALLOWED_CONVERSATION_IDS", "").strip() autorisees = None if liste == "*" else {u.strip() for u in liste.split(",") if u.strip()} - if ecrire and autorisees is not None and not autorisees: # « , » ne vaut pas « * » + if ecrire and autorisees is not None and not autorisees: # en écriture, « , » ne vaut pas « * » raise ValueError("DRY_RUN=false exige ALLOWED_CONVERSATION_IDS (des uuid séparés par des virgules, ou *)") + if not ecrire and not autorisees: # en simulation, sans liste : toutes + autorisees = None return Config(env["LIBREDESK_URL"], env["LIBREDESK_API_KEY"], env["LIBREDESK_API_SECRET"], ecrire, autorisees, int(env.get("MAX_CONVERSATIONS_PER_RUN") or 3), env.get("CONVERSATION", "").strip(), Path(env.get("AIMSIGHT_DATA") or "data"), diff --git a/tests/test_run.py b/tests/test_run.py index 0eb1e46..907fbdf 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -76,6 +76,11 @@ class TestConfig(unittest.TestCase): self.assertIsNone(cfg().autorisees) self.assertEqual(cfg(ALLOWED_CONVERSATION_IDS="c1, c2").autorisees, {"c1", "c2"}) + def test_simulation_sans_liste_blanche_traite_tout(self): + self.assertIsNone(Config.depuis_env(ENV).autorisees) + ld = FauxLD({"c1": []}, ecrire=False) + self.assertEqual(traiter(ld, Config.depuis_env({**ENV, "CONVERSATION": "c1"}), diag_fait), {"c1": "fait"}) + def test_liste_blanche_mal_formee(self): for v in (",", " , ", ",,"): with self.assertRaises(ValueError, msg=v):