1
0
forked from ScoDoc/ScoDoc

Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into refactor_nt

This commit is contained in:
Emmanuel Viennet 2022-01-04 23:55:20 +01:00
commit 88e15367b0
2 changed files with 21 additions and 15 deletions

View File

@ -49,9 +49,7 @@ class Module(db.Model):
super(Module, self).__init__(**kwargs) super(Module, self).__init__(**kwargs)
def __repr__(self): def __repr__(self):
return ( return f"<Module{ModuleType(self.module_type or ModuleType.STANDARD).name} id={self.id} code={self.code}>"
f"<Module{ModuleType(self.module_type).name} id={self.id} code={self.code}>"
)
def to_dict(self): def to_dict(self):
e = dict(self.__dict__) e = dict(self.__dict__)

View File

@ -42,17 +42,17 @@
# - do_formation_delete # - do_formation_delete
import json import json
import xml.dom.minidom
import flask import flask
from flask import g from flask import g
import pytest
from tests.unit import sco_fake_gen from tests.unit import sco_fake_gen
from app.scodoc import sco_edit_formation from app.scodoc import sco_edit_formation
from app.scodoc import sco_edit_matiere from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
from app.scodoc import sco_exceptions
from app.scodoc import sco_formations from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre_edit from app.scodoc import sco_formsemestre_edit
from app.scodoc import sco_moduleimpl from app.scodoc import sco_moduleimpl
@ -273,19 +273,31 @@ def test_formations(test_client):
# --- Suppression du module, matiere et ue test du semestre 2 # --- Suppression du module, matiere et ue test du semestre 2
# on doit d'abbord supprimer le semestre # on doit d'abord supprimer le semestre:
sco_formsemestre_edit.do_formsemestre_delete( sco_formsemestre_edit.do_formsemestre_delete(
formsemestre_id=sem2["formsemestre_id"] formsemestre_id=sem2["formsemestre_id"]
) )
li_module = sco_edit_module.module_list() li_module = sco_edit_module.module_list()
assert len(li_module) == 4 assert len(li_module) == 4
sco_edit_module.do_module_delete(oid=modt["module_id"]) # on supprime le semestre # Suppression impossible car utilisé dans le semestre semt:
# sco_formsemestre_edit.formsemestre_delete_moduleimpls( formsemestre_id=sem2["formsemestre_id"], module_ids_to_del=[modt["module_id"]]) with pytest.raises(sco_exceptions.ScoNonEmptyFormationObject):
# deuxieme methode de supression d'un module sco_edit_module.module_delete(module_id=mi3["module_id"])
li_module2 = sco_edit_module.module_list()
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"]) lim_sem2 = sco_moduleimpl.moduleimpl_list(formsemestre_id=sem2["formsemestre_id"])
@ -304,10 +316,6 @@ def test_formations(test_client):
assert len(li_ue2) == 3 # verification de la suppression de l'UE assert len(li_ue2) == 3 # verification de la suppression de l'UE
# --- Suppression d'une formation # --- 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"]) sco_edit_formation.do_formation_delete(oid=f2["formation_id"])
lif3 = notes.formation_list(format="json").get_data(as_text=True) lif3 = notes.formation_list(format="json").get_data(as_text=True)