2021-07-30 09:36:30 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Test de base de ScoDoc
|
|
|
|
|
|
|
|
|
|
|
|
Utiliser comme:
|
|
|
|
pytest tests/unit/test_sco_basic.py
|
|
|
|
|
2021-08-13 00:34:58 +02:00
|
|
|
Au besoin, créer un base de test neuve:
|
|
|
|
./tools/create_database.sh SCODOC_TEST
|
2021-07-31 18:01:10 +02:00
|
|
|
|
2021-07-30 09:36:30 +02:00
|
|
|
"""
|
2022-11-12 17:28:05 +01:00
|
|
|
from app.models import FormSemestreInscription, Identite
|
2021-07-30 09:36:30 +02:00
|
|
|
|
2021-08-10 12:57:38 +02:00
|
|
|
from config import TestConfig
|
2021-07-30 09:36:30 +02:00
|
|
|
from tests.unit import sco_fake_gen
|
2022-11-22 13:13:16 +01:00
|
|
|
from tests.unit.setup import NOTES_T
|
2021-07-30 09:36:30 +02:00
|
|
|
|
2021-08-13 00:34:58 +02:00
|
|
|
import app
|
2022-07-07 16:24:52 +02:00
|
|
|
from app import db
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.comp import res_sem
|
2022-03-27 22:25:00 +02:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2022-02-13 23:53:11 +01:00
|
|
|
from app.models import FormSemestre
|
|
|
|
from app.scodoc import sco_formsemestre
|
2021-07-30 09:36:30 +02:00
|
|
|
from app.scodoc import sco_abs
|
|
|
|
from app.scodoc import sco_abs_views
|
|
|
|
from app.scodoc import sco_bulletins
|
|
|
|
from app.scodoc import sco_codes_parcours
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_evaluations
|
2021-11-12 22:17:46 +01:00
|
|
|
from app.scodoc import sco_evaluation_db
|
2021-07-30 09:36:30 +02:00
|
|
|
from app.scodoc import sco_formsemestre_validation
|
2022-07-07 16:24:52 +02:00
|
|
|
from app.scodoc import sco_cursus_dut
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_saisie_notes
|
2021-07-30 09:36:30 +02:00
|
|
|
|
2021-08-10 12:57:38 +02:00
|
|
|
DEPT = TestConfig.DEPT_TEST
|
2021-07-30 09:36:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_sco_basic(test_client):
|
|
|
|
"""Test quelques opérations élémentaires de ScoDoc
|
|
|
|
Création 10 étudiants, formation, semestre, inscription etudiant,
|
|
|
|
creation 1 evaluation, saisie 10 notes.
|
|
|
|
"""
|
2021-08-13 00:34:58 +02:00
|
|
|
app.set_sco_dept(DEPT)
|
2021-08-10 12:57:38 +02:00
|
|
|
run_sco_basic()
|
|
|
|
|
|
|
|
|
2022-11-22 13:13:16 +01:00
|
|
|
def run_sco_basic(verbose=False) -> FormSemestre:
|
2021-08-10 12:57:38 +02:00
|
|
|
"""Scénario de base: création formation, semestre, étudiants, notes,
|
|
|
|
décisions jury
|
2022-11-22 13:13:16 +01:00
|
|
|
Renvoie le formsemestre créé.
|
2021-08-10 12:57:38 +02:00
|
|
|
"""
|
|
|
|
G = sco_fake_gen.ScoFake(verbose=verbose)
|
2021-07-30 09:36:30 +02:00
|
|
|
|
|
|
|
# --- Création d'étudiants
|
|
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
|
|
|
|
# --- Création d'une formation
|
2022-01-15 21:36:06 +01:00
|
|
|
formation_id = G.create_formation(acronyme="")
|
|
|
|
ue_id = G.create_ue(formation_id=formation_id, acronyme="TST1", titre="ue test")
|
|
|
|
matiere_id = G.create_matiere(ue_id=ue_id, titre="matière test")
|
|
|
|
module_id = G.create_module(
|
|
|
|
matiere_id=matiere_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
code="TSM1",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test",
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Mise place d'un semestre
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id = G.create_formsemestre(
|
|
|
|
formation_id=formation_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
semestre_id=1,
|
|
|
|
date_debut="01/01/2020",
|
|
|
|
date_fin="30/06/2020",
|
|
|
|
)
|
2022-01-15 21:36:06 +01:00
|
|
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
|
|
|
moduleimpl_id = G.create_moduleimpl(
|
|
|
|
module_id=module_id,
|
|
|
|
formsemestre_id=formsemestre_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# --- Inscription des étudiants
|
|
|
|
for etud in etuds:
|
2022-01-15 21:36:06 +01:00
|
|
|
G.inscrit_etudiant(formsemestre_id, etud)
|
2022-12-06 13:06:50 +01:00
|
|
|
|
2022-05-26 03:55:03 +02:00
|
|
|
# Vérification incription semestre:
|
|
|
|
q = FormSemestreInscription.query.filter_by(
|
2022-12-06 13:06:50 +01:00
|
|
|
etudid=etuds[0]["etudid"], formsemestre_id=formsemestre_id
|
2022-05-26 03:55:03 +02:00
|
|
|
)
|
|
|
|
assert q.count() == 1
|
|
|
|
ins = q.first()
|
2022-11-22 13:13:16 +01:00
|
|
|
assert ins.etape is None
|
2022-05-26 03:55:03 +02:00
|
|
|
assert ins.etat == "I"
|
2022-11-22 13:13:16 +01:00
|
|
|
assert ins.parcour is None
|
2021-07-30 09:36:30 +02:00
|
|
|
|
2022-11-22 13:13:16 +01:00
|
|
|
# --- Création évaluation
|
2021-07-30 09:36:30 +02:00
|
|
|
e = G.create_evaluation(
|
2022-01-15 21:36:06 +01:00
|
|
|
moduleimpl_id=moduleimpl_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
jour="01/01/2020",
|
|
|
|
description="evaluation test",
|
|
|
|
coefficient=1.0,
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Saisie toutes les notes de l'évaluation
|
2022-11-22 13:13:16 +01:00
|
|
|
for idx, etud in enumerate(etuds):
|
2021-07-30 09:36:30 +02:00
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
2022-12-06 13:06:50 +01:00
|
|
|
evaluation_id=e["id"],
|
|
|
|
etudid=etud["etudid"],
|
|
|
|
note=NOTES_T[idx % len(NOTES_T)],
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
2022-11-22 13:13:16 +01:00
|
|
|
assert not existing_decisions
|
|
|
|
assert nb_suppress == 0
|
|
|
|
assert nb_changed == 1
|
2021-07-30 09:36:30 +02:00
|
|
|
|
|
|
|
# --- Vérifie que les notes sont prises en compte:
|
2022-01-15 21:36:06 +01:00
|
|
|
b = sco_bulletins.formsemestre_bulletinetud_dict(formsemestre_id, etud["etudid"])
|
2021-07-30 09:36:30 +02:00
|
|
|
# Toute les notes sont saisies, donc eval complète
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
|
|
|
assert etat["evalcomplete"]
|
2021-07-31 18:01:10 +02:00
|
|
|
assert etat["nb_inscrits"] == len(etuds)
|
|
|
|
assert etat["nb_notes"] == len(etuds)
|
2021-07-30 09:36:30 +02:00
|
|
|
# Un seul module, donc moy gen == note module
|
|
|
|
assert b["ues"][0]["cur_moy_ue_txt"] == b["ues"][0]["modules"][0]["mod_moy_txt"]
|
|
|
|
# Note au module égale à celle de l'éval
|
|
|
|
assert (
|
|
|
|
b["ues"][0]["modules"][0]["mod_moy_txt"]
|
|
|
|
== b["ues"][0]["modules"][0]["evaluations"][0]["note_txt"]
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Une autre évaluation
|
|
|
|
e2 = G.create_evaluation(
|
2022-01-15 21:36:06 +01:00
|
|
|
moduleimpl_id=moduleimpl_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
jour="02/01/2020",
|
|
|
|
description="evaluation test 2",
|
|
|
|
coefficient=1.0,
|
|
|
|
)
|
|
|
|
# Saisie les notes des 5 premiers étudiants:
|
2022-11-22 13:13:16 +01:00
|
|
|
for idx, etud in enumerate(etuds[:5]):
|
2021-07-30 09:36:30 +02:00
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
2022-12-06 13:06:50 +01:00
|
|
|
evaluation_id=e2["id"],
|
|
|
|
etudid=etud["etudid"],
|
|
|
|
note=NOTES_T[idx % len(NOTES_T)],
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
|
|
|
# Cette éval n'est pas complète
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
2022-11-22 13:13:16 +01:00
|
|
|
assert etat["evalcomplete"] is False
|
2021-07-30 09:36:30 +02:00
|
|
|
# la première éval est toujours complète:
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
|
|
|
assert etat["evalcomplete"]
|
|
|
|
|
|
|
|
# Modifie l'évaluation 2 pour "prise en compte immédiate"
|
2021-08-11 00:36:07 +02:00
|
|
|
e2["publish_incomplete"] = True
|
2021-11-12 22:17:46 +01:00
|
|
|
sco_evaluation_db.do_evaluation_edit(e2)
|
2021-07-30 09:36:30 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
2022-11-22 13:13:16 +01:00
|
|
|
assert etat["evalcomplete"] is False
|
2021-07-30 09:36:30 +02:00
|
|
|
assert etat["nb_att"] == 0 # il n'y a pas de notes (explicitement) en attente
|
|
|
|
assert etat["evalattente"] # mais l'eval est en attente (prise en compte immédiate)
|
|
|
|
|
|
|
|
# Saisie des notes qui manquent:
|
2022-11-22 13:13:16 +01:00
|
|
|
for idx, etud in enumerate(etuds[5:]):
|
2021-07-30 09:36:30 +02:00
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
2022-12-06 13:06:50 +01:00
|
|
|
evaluation_id=e2["id"],
|
|
|
|
etudid=etud["etudid"],
|
|
|
|
note=NOTES_T[idx % len(NOTES_T)],
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
|
|
|
assert etat["evalcomplete"]
|
|
|
|
assert etat["nb_att"] == 0
|
|
|
|
assert not etat["evalattente"] # toutes les notes sont présentes
|
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
# --- Suppression des notes
|
|
|
|
sco_saisie_notes.evaluation_suppress_alln(e["evaluation_id"], dialog_confirmed=True)
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
|
|
|
assert etat["nb_notes"] == 0
|
|
|
|
assert not etat["evalcomplete"]
|
|
|
|
# --- Saisie des notes manquantes
|
|
|
|
ans = sco_saisie_notes.do_evaluation_set_missing(
|
|
|
|
e["evaluation_id"], 12.34, dialog_confirmed=True
|
|
|
|
)
|
|
|
|
assert f'{etat["nb_inscrits"]} notes changées' in ans
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e["evaluation_id"])
|
|
|
|
assert etat["evalcomplete"]
|
2022-11-22 13:13:16 +01:00
|
|
|
|
|
|
|
# -----------------------
|
|
|
|
# --- Saisie absences ---
|
|
|
|
# -----------------------
|
2021-07-30 09:36:30 +02:00
|
|
|
etudid = etuds[0]["etudid"]
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
2021-08-21 00:24:51 +02:00
|
|
|
"15/01/2020", "18/01/2020", demijournee=2, etudid=etudid
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
|
|
|
"17/01/2020",
|
|
|
|
"18/01/2020",
|
|
|
|
demijournee=2,
|
|
|
|
etudid=etudid,
|
|
|
|
)
|
|
|
|
|
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
2022-11-22 13:13:16 +01:00
|
|
|
assert nbabs == 6, f"incorrect nbabs ({nbabs})"
|
|
|
|
assert nbabsjust == 2, f"incorrect nbabsjust ({nbabsjust})"
|
2021-07-30 09:36:30 +02:00
|
|
|
|
|
|
|
# --- Permission saisie notes et décisions de jury, avec ou sans démission ou défaillance
|
|
|
|
# on n'a pas encore saisi de décisions
|
2022-07-07 16:24:52 +02:00
|
|
|
assert not sco_cursus_dut.formsemestre_has_decisions(formsemestre_id)
|
2021-07-30 09:36:30 +02:00
|
|
|
# Saisie d'un décision AJ, non assidu
|
|
|
|
etudid = etuds[-1]["etudid"]
|
2022-07-07 16:24:52 +02:00
|
|
|
sco_cursus_dut.formsemestre_validate_ues(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id, etudid, sco_codes_parcours.AJ, False
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
2022-07-07 16:24:52 +02:00
|
|
|
assert sco_cursus_dut.formsemestre_has_decisions(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id
|
2021-07-30 09:36:30 +02:00
|
|
|
), "décisions manquantes"
|
|
|
|
# Suppression de la décision
|
|
|
|
sco_formsemestre_validation.formsemestre_validation_suppress_etud(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id, etudid
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
2022-07-07 16:24:52 +02:00
|
|
|
assert not sco_cursus_dut.formsemestre_has_decisions(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id
|
2021-07-30 09:36:30 +02:00
|
|
|
), "décisions non effacées"
|
2021-09-30 14:35:21 +02:00
|
|
|
|
|
|
|
# --- Décision de jury et validations des ECTS d'UE
|
|
|
|
for etud in etuds[:5]: # les etudiants notés
|
|
|
|
sco_formsemestre_validation.formsemestre_validation_etud_manu(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id,
|
2021-09-30 14:35:21 +02:00
|
|
|
etud["etudid"],
|
|
|
|
code_etat=sco_codes_parcours.ADJ,
|
|
|
|
assidu=True,
|
|
|
|
redirect=False,
|
|
|
|
)
|
|
|
|
# Vérifie que toutes les UE des étudiants notés ont été acquises:
|
2022-02-13 23:53:11 +01:00
|
|
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
|
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
2021-09-30 14:35:21 +02:00
|
|
|
for etud in etuds[:5]:
|
|
|
|
dec_ues = nt.get_etud_decision_ues(etud["etudid"])
|
|
|
|
for ue_id in dec_ues:
|
|
|
|
assert dec_ues[ue_id]["code"] in {"ADM", "CMP"}
|
2022-05-26 03:55:03 +02:00
|
|
|
|
2022-11-22 13:13:16 +01:00
|
|
|
# ---- Suppression d'un étudiant, vérification inscription
|
2022-05-26 03:55:03 +02:00
|
|
|
# (permet de tester les cascades)
|
2022-12-06 13:06:50 +01:00
|
|
|
etud = Identite.query.get(etuds[0]["etudid"])
|
2022-11-12 17:28:05 +01:00
|
|
|
assert etud is not None
|
2022-05-26 03:55:03 +02:00
|
|
|
etudid = etud.id
|
|
|
|
db.session.delete(etud)
|
|
|
|
db.session.commit()
|
|
|
|
# Vérification incription semestre:
|
|
|
|
q = FormSemestreInscription.query.filter_by(
|
|
|
|
etudid=etudid, formsemestre_id=formsemestre_id
|
|
|
|
)
|
|
|
|
assert q.count() == 0
|
2022-11-22 13:13:16 +01:00
|
|
|
return formsemestre
|