From 5895e5c33c172b3414d2d5930c1526de14c881a2 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 4 Jan 2022 23:05:37 +0100 Subject: [PATCH] edition formations / tests unitaires ok --- app/models/modules.py | 4 +--- app/scodoc/sco_edit_ue.py | 4 ++-- tests/unit/test_formations.py | 42 ++++++++++++++++------------------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/app/models/modules.py b/app/models/modules.py index 00a6d4c9..8f305507 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -49,9 +49,7 @@ class Module(db.Model): super(Module, self).__init__(**kwargs) def __repr__(self): - return ( - f"" - ) + return f"" def to_dict(self): e = dict(self.__dict__) diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index c93bdb1b..766fbd9b 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -211,7 +211,7 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): F = sco_formations.formation_list(args={"formation_id": ue.formation_id})[0] sco_news.add( typ=sco_news.NEWS_FORM, - object=ue["formation_id"], + object=ue.formation_id, text="Modification de la formation %(acronyme)s" % F, max_frequency=3, ) @@ -221,7 +221,7 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, - formation_id=ue["formation_id"], + formation_id=ue.formation_id, semestre_idx=ue.semestre_idx, ) ) diff --git a/tests/unit/test_formations.py b/tests/unit/test_formations.py index 613d3573..786ccba2 100644 --- a/tests/unit/test_formations.py +++ b/tests/unit/test_formations.py @@ -42,17 +42,17 @@ # - do_formation_delete import json -import xml.dom.minidom import flask from flask import g - +import pytest from tests.unit import sco_fake_gen from app.scodoc import sco_edit_formation from app.scodoc import sco_edit_matiere from app.scodoc import sco_edit_module from app.scodoc import sco_edit_ue +from app.scodoc import sco_exceptions from app.scodoc import sco_formations from app.scodoc import sco_formsemestre_edit from app.scodoc import sco_moduleimpl @@ -273,31 +273,31 @@ def test_formations(test_client): # --- Suppression du module, matiere et ue test du semestre 2 - # on doit d'abbord supprimer le semestre - - # sco_formsemestre_edit.formsemestre_delete( formsemestre_id=sem2["formsemestre_id"]) - # sco_formsemestre_edit.formsemestre_createwithmodules( formsemestre_id=sem2["formsemestre_id"]) - - # RIEN NE SE PASSE AVEC CES FONCTIONS + # on doit d'abord supprimer le semestre: sco_formsemestre_edit.do_formsemestre_delete( formsemestre_id=sem2["formsemestre_id"] ) - # sco_edit_module.module_delete( module_id=modt["module_id"]) - # sco_edit_matiere.matiere_delete( matiere_id=matt["matiere_id"]) - # sco_edit_ue.ue_delete( ue_id=uet["ue_id"]) - - # RIEN NE SE PASSE AVEC CES FONCTIONS - li_module = sco_edit_module.module_list() assert len(li_module) == 4 - sco_edit_module.do_module_delete(oid=modt["module_id"]) # on supprime le semestre - # sco_formsemestre_edit.formsemestre_delete_moduleimpls( formsemestre_id=sem2["formsemestre_id"], module_ids_to_del=[modt["module_id"]]) - # deuxieme methode de supression d'un module - li_module2 = sco_edit_module.module_list() + # Suppression impossible car utilisé dans le semestre semt: + with pytest.raises(sco_exceptions.ScoNonEmptyFormationObject): + sco_edit_module.module_delete(module_id=mi3["module_id"]) - assert len(li_module2) == 3 # verification de la suppression du module + sco_formsemestre_edit.do_formsemestre_delete(semt["formsemestre_id"]) + + li_module2_before = sco_edit_module.module_list() + + sco_edit_module.do_module_delete(mi3["module_id"]) + sco_edit_module.do_module_delete(modt["module_id"]) + + # deuxieme methode de supression d'un module + li_module2_after = sco_edit_module.module_list() + + assert ( + len(li_module2_after) == len(li_module2_before) - 2 + ) # verification de la suppression lim_sem2 = sco_moduleimpl.moduleimpl_list(formsemestre_id=sem2["formsemestre_id"]) @@ -316,10 +316,6 @@ def test_formations(test_client): assert len(li_ue2) == 3 # verification de la suppression de l'UE # --- Suppression d'une formation - # Il faut d'abbord supprimer le semestre aussi. - sco_formsemestre_edit.do_formsemestre_delete( - formsemestre_id=semt["formsemestre_id"] - ) sco_edit_formation.do_formation_delete(oid=f2["formation_id"]) lif3 = notes.formation_list(format="json").get_data(as_text=True)