Fix unit tests
This commit is contained in:
parent
9c618692d1
commit
51b0ca088c
@ -341,7 +341,7 @@ def formsemestre_etudiants(
|
||||
# XXX A REVOIR: trop inefficace !
|
||||
for etud in etuds:
|
||||
etud["groups"] = sco_groups.get_etud_groups(
|
||||
etud["id"], formsemestre_id, exclude_default=True
|
||||
etud["etudid"], formsemestre_id, exclude_default=True
|
||||
)
|
||||
|
||||
return jsonify(sorted(etuds, key=lambda e: e["sort_key"]))
|
||||
|
@ -284,9 +284,9 @@ def formsemestre_bulletinetud_published_dict(
|
||||
d["ue_capitalisee"].append(
|
||||
dict(
|
||||
id=ue_id,
|
||||
numero=quote_xml_attr(ue.numero),
|
||||
acronyme=quote_xml_attr(ue.acronyme),
|
||||
titre=quote_xml_attr(ue.titre),
|
||||
numero=quote_xml_attr(ue_st["numero"]),
|
||||
acronyme=quote_xml_attr(ue_st["acronyme"]),
|
||||
titre=quote_xml_attr(ue_st["titre"]),
|
||||
note=scu.fmt_note(ue_status["moy"]),
|
||||
coefficient_ue=scu.fmt_note(ue_status["coef_ue"]),
|
||||
date_capitalisation=ndb.DateDMYtoISO(ue_status["event_date"]),
|
||||
|
@ -286,7 +286,8 @@ def do_formsemestre_inscription_with_modules(
|
||||
args["etape"] = etape
|
||||
do_formsemestre_inscription_create(args, method=method)
|
||||
log(
|
||||
f"do_formsemestre_inscription_with_modules: etudid={etudid} formsemestre_id={formsemestre_id}"
|
||||
f"""do_formsemestre_inscription_with_modules: etudid={
|
||||
etudid} formsemestre_id={formsemestre_id}"""
|
||||
)
|
||||
# inscriptions aux groupes
|
||||
# 1- inscrit au groupe 'tous'
|
||||
@ -296,7 +297,7 @@ def do_formsemestre_inscription_with_modules(
|
||||
|
||||
# 2- inscrit aux groupes
|
||||
for group_id in group_ids:
|
||||
if group_id and not group_id in gdone:
|
||||
if group_id and group_id not in gdone:
|
||||
group = GroupDescr.query.get_or_404(group_id)
|
||||
sco_groups.set_group(etudid, group_id)
|
||||
gdone[group_id] = 1
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.4.9"
|
||||
SCOVERSION = "9.4.10"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
@ -76,6 +76,7 @@ def test_etudiants_courant(api_headers):
|
||||
|
||||
etud = etudiants[-1]
|
||||
assert verify_fields(etud, fields) is True
|
||||
assert etud["id"] == etud["etudid"]
|
||||
assert isinstance(etud["id"], int)
|
||||
assert isinstance(etud["code_nip"], str)
|
||||
assert isinstance(etud["nom"], str)
|
||||
|
@ -421,7 +421,7 @@ class ScoFake(object):
|
||||
for idx, etud in enumerate(etuds):
|
||||
self.create_note(
|
||||
evaluation_id=e["id"],
|
||||
etudid=etud["id"],
|
||||
etudid=etud["etudid"],
|
||||
note=notes[idx % len(notes)],
|
||||
)
|
||||
|
||||
|
@ -77,6 +77,7 @@ def test_ue_moy(test_client):
|
||||
modimpl_inscr_df,
|
||||
modimpl_coefs_df,
|
||||
modimpl_mask,
|
||||
set(),
|
||||
)
|
||||
return etud_moy_ue
|
||||
|
||||
@ -122,7 +123,13 @@ def test_ue_moy(test_client):
|
||||
modimpl.module.ue.type != UE_SPORT for modimpl in formsemestre.modimpls_sorted
|
||||
]
|
||||
etud_moy_ue = moy_ue.compute_ue_moys_apc(
|
||||
sem_cube, etuds, modimpls, modimpl_inscr_df, modimpl_coefs_df, modimpl_mask
|
||||
sem_cube,
|
||||
etuds,
|
||||
modimpls,
|
||||
modimpl_inscr_df,
|
||||
modimpl_coefs_df,
|
||||
modimpl_mask,
|
||||
set(),
|
||||
)
|
||||
assert etud_moy_ue[ue1.id][etudid] == n1
|
||||
assert etud_moy_ue[ue2.id][etudid] == n1
|
||||
|
@ -106,13 +106,17 @@ def test_notes_modules(test_client):
|
||||
# --- Notes ordinaires
|
||||
note_1 = 12.0
|
||||
note_2 = 13.0
|
||||
_, _, _ = G.create_note(evaluation_id=e1["id"], etudid=etuds[0]["id"], note=note_1)
|
||||
_, _, _ = G.create_note(evaluation_id=e2["id"], etudid=etuds[0]["id"], note=note_2)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["id"], note=note_1 / 2
|
||||
evaluation_id=e1["id"], etudid=etuds[0]["etudid"], note=note_1
|
||||
)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e2["id"], etudid=etuds[1]["id"], note=note_2 / 3
|
||||
evaluation_id=e2["id"], etudid=etuds[0]["etudid"], note=note_2
|
||||
)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["etudid"], note=note_1 / 2
|
||||
)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e2["id"], etudid=etuds[1]["etudid"], note=note_2 / 3
|
||||
)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
@ -316,9 +320,15 @@ def test_notes_modules(test_client):
|
||||
evaluation_id=e2["id"], etudid=etudid, note=scu.NOTES_NEUTRALISE
|
||||
) # EXC
|
||||
_, _, _ = G.create_note(evaluation_id=e_m2["id"], etudid=etudid, note=12.5)
|
||||
_, _, _ = G.create_note(evaluation_id=e1["id"], etudid=etuds[1]["id"], note=11.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e2["id"], etudid=etuds[1]["id"], note=11.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_m2["id"], etudid=etuds[1]["id"], note=11.0)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["etudid"], note=11.0
|
||||
)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e2["id"], etudid=etuds[1]["etudid"], note=11.0
|
||||
)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e_m2["id"], etudid=etuds[1]["etudid"], note=11.0
|
||||
)
|
||||
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
@ -381,10 +391,10 @@ def test_notes_modules_att_dem(test_client):
|
||||
)
|
||||
# Attente (ATT) sur les 2 evals
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[0]["id"], note=scu.NOTES_ATTENTE
|
||||
evaluation_id=e1["id"], etudid=etuds[0]["etudid"], note=scu.NOTES_ATTENTE
|
||||
) # ATT
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["id"], note=scu.NOTES_ATTENTE
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["etudid"], note=scu.NOTES_ATTENTE
|
||||
) # ATT
|
||||
# Démission du premier étudiant
|
||||
sco_formsemestre_inscriptions.do_formsemestre_demission(
|
||||
@ -424,7 +434,9 @@ def test_notes_modules_att_dem(test_client):
|
||||
assert note_e1 == scu.NOTES_ATTENTE # XXXX un peu contestable
|
||||
|
||||
# Saisie note ABS pour le deuxième etud
|
||||
_, _, _ = G.create_note(evaluation_id=e1["id"], etudid=etuds[1]["id"], note=None)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e1["id"], etudid=etuds[1]["etudid"], note=None
|
||||
)
|
||||
nt = check_nt(
|
||||
etuds[1]["etudid"],
|
||||
sem["formsemestre_id"],
|
||||
|
@ -71,8 +71,8 @@ def test_notes_rattrapage(test_client):
|
||||
evaluation_type=scu.EVALUATION_RATTRAPAGE,
|
||||
)
|
||||
etud = etuds[0]
|
||||
_, _, _ = G.create_note(evaluation_id=e["id"], etudid=etud["id"], note=12.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["id"], note=11.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e["id"], etudid=etud["etudid"], note=12.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["etudid"], note=11.0)
|
||||
|
||||
# --- Vérifications internes structures ScoDoc
|
||||
formsemestre = FormSemestre.query.get(formsemestre_id)
|
||||
@ -96,21 +96,23 @@ def test_notes_rattrapage(test_client):
|
||||
# Note moyenne: ici le ratrapage est inférieur à la note:
|
||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(12.0)
|
||||
# rattrapage > moyenne:
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["id"], note=18.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["etudid"], note=18.0)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
)
|
||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(18.0)
|
||||
# rattrapage vs absences
|
||||
_, _, _ = G.create_note(evaluation_id=e["id"], etudid=etud["id"], note=None) # abs
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["id"], note=17.0)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e["id"], etudid=etud["etudid"], note=None
|
||||
) # abs
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["etudid"], note=17.0)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
)
|
||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(17.0)
|
||||
# et sans note de rattrapage
|
||||
_, _, _ = G.create_note(evaluation_id=e["id"], etudid=etud["id"], note=10.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["id"], note=None)
|
||||
_, _, _ = G.create_note(evaluation_id=e["id"], etudid=etud["etudid"], note=10.0)
|
||||
_, _, _ = G.create_note(evaluation_id=e_rat["id"], etudid=etud["etudid"], note=None)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
)
|
||||
@ -152,7 +154,9 @@ def test_notes_rattrapage(test_client):
|
||||
assert len(mod_res.get_evaluations_completes(moduleimpl)) == 2
|
||||
|
||||
# Saisie note session 2:
|
||||
_, _, _ = G.create_note(evaluation_id=e_session2["id"], etudid=etud["id"], note=5.0)
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e_session2["id"], etudid=etud["etudid"], note=5.0
|
||||
)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
)
|
||||
@ -160,7 +164,7 @@ def test_notes_rattrapage(test_client):
|
||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(5.0)
|
||||
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e_session2["id"], etudid=etud["id"], note=20.0
|
||||
evaluation_id=e_session2["id"], etudid=etud["etudid"], note=20.0
|
||||
)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
@ -169,7 +173,7 @@ def test_notes_rattrapage(test_client):
|
||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(20.0)
|
||||
|
||||
_, _, _ = G.create_note(
|
||||
evaluation_id=e_session2["id"], etudid=etud["id"], note=None
|
||||
evaluation_id=e_session2["id"], etudid=etud["etudid"], note=None
|
||||
)
|
||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||
sem["formsemestre_id"], etud["etudid"]
|
||||
|
@ -82,9 +82,10 @@ def run_sco_basic(verbose=False) -> FormSemestre:
|
||||
# --- Inscription des étudiants
|
||||
for etud in etuds:
|
||||
G.inscrit_etudiant(formsemestre_id, etud)
|
||||
|
||||
# Vérification incription semestre:
|
||||
q = FormSemestreInscription.query.filter_by(
|
||||
etudid=etuds[0]["id"], formsemestre_id=formsemestre_id
|
||||
etudid=etuds[0]["etudid"], formsemestre_id=formsemestre_id
|
||||
)
|
||||
assert q.count() == 1
|
||||
ins = q.first()
|
||||
@ -103,7 +104,9 @@ def run_sco_basic(verbose=False) -> FormSemestre:
|
||||
# --- Saisie toutes les notes de l'évaluation
|
||||
for idx, etud in enumerate(etuds):
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
||||
evaluation_id=e["id"], etudid=etud["id"], note=NOTES_T[idx % len(NOTES_T)]
|
||||
evaluation_id=e["id"],
|
||||
etudid=etud["etudid"],
|
||||
note=NOTES_T[idx % len(NOTES_T)],
|
||||
)
|
||||
assert not existing_decisions
|
||||
assert nb_suppress == 0
|
||||
@ -134,7 +137,9 @@ def run_sco_basic(verbose=False) -> FormSemestre:
|
||||
# Saisie les notes des 5 premiers étudiants:
|
||||
for idx, etud in enumerate(etuds[:5]):
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
||||
evaluation_id=e2["id"], etudid=etud["id"], note=NOTES_T[idx % len(NOTES_T)]
|
||||
evaluation_id=e2["id"],
|
||||
etudid=etud["etudid"],
|
||||
note=NOTES_T[idx % len(NOTES_T)],
|
||||
)
|
||||
# Cette éval n'est pas complète
|
||||
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
||||
@ -154,7 +159,9 @@ def run_sco_basic(verbose=False) -> FormSemestre:
|
||||
# Saisie des notes qui manquent:
|
||||
for idx, etud in enumerate(etuds[5:]):
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
||||
evaluation_id=e2["id"], etudid=etud["id"], note=NOTES_T[idx % len(NOTES_T)]
|
||||
evaluation_id=e2["id"],
|
||||
etudid=etud["etudid"],
|
||||
note=NOTES_T[idx % len(NOTES_T)],
|
||||
)
|
||||
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
||||
assert etat["evalcomplete"]
|
||||
@ -232,7 +239,7 @@ def run_sco_basic(verbose=False) -> FormSemestre:
|
||||
|
||||
# ---- Suppression d'un étudiant, vérification inscription
|
||||
# (permet de tester les cascades)
|
||||
etud = Identite.query.get(etuds[0]["id"])
|
||||
etud = Identite.query.get(etuds[0]["etudid"])
|
||||
assert etud is not None
|
||||
etudid = etud.id
|
||||
db.session.delete(etud)
|
||||
|
Loading…
Reference in New Issue
Block a user