fiches : pas 5, les lecteurs du fichier de fiche suivent la filiation

index_attribue suit le chemin de la fiche (presentee, attribution du site,
deposee) : sans lui la copie de reprise se regenerait sous l'index de
production. site_ou_vit, depot_locataire et racines lisent la production
dans parente.yml (underlay.site_de_production). Console et tests suivis.
Conception et CHANGELOG 210.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Allaire 2026-10-25 16:26:03 -04:00
parent 83fef75100
commit f75f561183
9 changed files with 111 additions and 32 deletions

View file

@ -69,6 +69,31 @@ class Fictif(unittest.TestCase):
(self.d / "OPS-X" / "fiche-site.yml").unlink()
self.assertEqual(inventory_rules.charger_nomenclature(self.d / "OPS-X" / "plan" / "nomenclature.yml")["index"], 23)
# 10. SANS FICHE DEPOSEE (2026-10-25, §2.5 pas 5) ------------------------------------
# Le site ne depose plus sa fiche. La copie de reprise se regenerait alors sous l'index de
# PRODUCTION (23) : `index_attribue` ne lisait que le fichier. Elle tient desormais son index du
# site de reprise (son chemin le nomme), et la production le sien (sa filiation).
def test_sans_fiche_la_copie_garde_l_index_de_reprise(self):
(self.d / "OPS-X" / "fiche-site.yml").unlink()
copie = self.d / "reprises" / "SITE-Reprise" / "OPS-X"
ecrire(copie / "plan" / "nomenclature.yml", {"index": 23})
ecrire(copie / "parente.yml", {"parente": {"depots": {"hebergeur": {"nom": "SITE-Prod"}}}})
with mock.patch.object(contexte, "DOSSIER_ECOSYSTEMES", self.d):
n = inventory_rules.charger_nomenclature(copie / "plan" / "nomenclature.yml")
self.assertEqual((n["index"], n.get("index_production")), (43, 23))
n = inventory_rules.charger_nomenclature(self.d / "OPS-X" / "plan" / "nomenclature.yml")
self.assertEqual(n["index"], 23)
def test_sans_fiche_la_production_vit_chez_son_hebergeur(self):
(self.d / "OPS-X" / "fiche-site.yml").unlink()
self.assertEqual(underlay.site_de_production(self.d / "OPS-X"), "SITE-Prod")
with mock.patch.object(devis_reseau, "DOSSIER_INSTANCES", self.d):
self.assertEqual(devis_reseau.site_ou_vit("OPS-X"), "SITE-Prod")
c = self.copie()
(c / "fiche-site.yml").unlink(missing_ok=True)
self.assertEqual(underlay.depot_locataire("OPS-X", self.d, "SITE-Reprise"), c)
self.assertEqual(underlay.depot_locataire("OPS-X", self.d, "SITE-Prod"), self.d / "OPS-X")
# 2. ----------------------------------------------------------------------------------
def test_l_hebergeur_attribue_la_production(self):
self.assertEqual(contexte.Site(self.d / "SITE-Prod").ecarts_attribution(self.loc), [])