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):