From 21b5474a6f28d9174abc36e774384a5967a58975 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 31 Jan 2023 14:58:24 -0300 Subject: [PATCH] Fix test unit: test_formations --- app/models/formations.py | 2 +- app/scodoc/sco_formations.py | 1 + tests/unit/test_formations.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/formations.py b/app/models/formations.py index 5bd4a8d9..d4aac9ad 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -64,7 +64,7 @@ class Formation(db.Model): return f"""Formation {self.titre} ({self.acronyme}) [version {self.version}] code {self.formation_code}""" def to_dict(self, with_refcomp_attrs=False): - """ "as a dict. + """As a dict. Si with_refcomp_attrs, ajoute attributs permettant de retrouver le ref. de comp. """ e = dict(self.__dict__) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index 9be52db4..93f64734 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -119,6 +119,7 @@ def formation_export( formation: Formation = Formation.query.get_or_404(formation_id) f_dict = formation.to_dict(with_refcomp_attrs=True) if not export_ids: + del f_dict["id"] del f_dict["formation_id"] del f_dict["dept_id"] ues = formation.ues diff --git a/tests/unit/test_formations.py b/tests/unit/test_formations.py index c91a4cf8..38a40378 100644 --- a/tests/unit/test_formations.py +++ b/tests/unit/test_formations.py @@ -178,7 +178,7 @@ def test_formations(test_client): # --- Export de formation_id exp = sco_formations.formation_export( - formation_id=formation_id, format="json" + formation_id=formation_id, format="json", export_ids=True ).get_data(as_text=True) assert isinstance(exp, str) load_exp = json.loads(exp)