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
|
|
|
"""
|
|
|
|
import random
|
|
|
|
|
|
|
|
from flask import g
|
2022-07-05 16:09:26 +02:00
|
|
|
from app.models.formsemestre import FormSemestreInscription
|
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
|
|
|
|
|
2021-08-13 00:34:58 +02:00
|
|
|
import app
|
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
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_parcours_dut
|
2021-09-30 14:35:21 +02:00
|
|
|
from app.scodoc import sco_cache
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_saisie_notes
|
|
|
|
from app.scodoc import sco_utils as scu
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
def run_sco_basic(verbose=False):
|
|
|
|
"""Scénario de base: création formation, semestre, étudiants, notes,
|
|
|
|
décisions jury
|
|
|
|
"""
|
|
|
|
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",
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id=ue_id,
|
|
|
|
formation_id=formation_id,
|
2021-07-30 09:36:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# --- 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-07-05 16:09:26 +02:00
|
|
|
# Vérification incription semestre:
|
|
|
|
q = FormSemestreInscription.query.filter_by(
|
|
|
|
etudid=etuds[0].id, formsemestre_id=formsemestre_id
|
|
|
|
)
|
|
|
|
assert q.count() == 1
|
|
|
|
ins = q.first()
|
|
|
|
assert ins.etape == None
|
|
|
|
assert ins.etat == "I"
|
|
|
|
assert ins.parcour == None
|
2021-07-30 09:36:30 +02:00
|
|
|
|
|
|
|
# --- Creation évaluation
|
|
|
|
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
|
|
|
|
for etud in etuds:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- 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:
|
|
|
|
for etud in etuds[:5]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e2, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
|
|
|
# Cette éval n'est pas complète
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(e2["evaluation_id"])
|
|
|
|
assert etat["evalcomplete"] == False
|
|
|
|
# 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"])
|
|
|
|
assert etat["evalcomplete"] == False
|
|
|
|
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:
|
|
|
|
for etud in etuds[5:]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e2, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
|
|
|
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"]
|
2021-07-30 09:36:30 +02:00
|
|
|
# --- Saisie absences
|
|
|
|
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)
|
|
|
|
assert nbabs == 6, "incorrect nbabs (%d)" % nbabs
|
|
|
|
assert nbabsjust == 2, "incorrect nbabsjust (%s)" % nbabsjust
|
|
|
|
|
|
|
|
# --- 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-01-15 21:36:06 +01:00
|
|
|
assert not sco_parcours_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"]
|
|
|
|
sco_parcours_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
|
|
|
)
|
|
|
|
assert sco_parcours_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
|
|
|
)
|
|
|
|
assert not sco_parcours_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-07-05 16:09:26 +02:00
|
|
|
|
|
|
|
# ---- Suppression étudiant, vérification inscription
|
|
|
|
# (permet de tester les cascades)
|
|
|
|
etud = etuds[0]
|
|
|
|
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
|