forked from ScoDoc/ScoDoc
98 lines
2.4 KiB
Python
98 lines
2.4 KiB
Python
# -*- mode: python -*-
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""Test de base de ScoDoc
|
|
|
|
Création 10 étudiants, formation, semestre, inscription etudiant, creation 1 evaluation, saisie 10 notes.
|
|
|
|
Utiliser comme:
|
|
scotests/scointeractive.sh -r TEST00 scotests/test_basic.py
|
|
|
|
"""
|
|
import random
|
|
|
|
# La variable context est définie par le script de lancement
|
|
# l'affecte ainsi pour évietr les warnins pylint:
|
|
context = context # pylint: disable=undefined-variable
|
|
REQUEST = REQUEST # pylint: disable=undefined-variable
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
import sco_utils
|
|
import sco_abs
|
|
import sco_abs_views
|
|
|
|
G = sco_fake_gen.ScoFake(context.Notes)
|
|
G.verbose = False
|
|
|
|
# --- Création d'étudiants
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
# --- Création d'une formation
|
|
f = G.create_formation(acronyme="")
|
|
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
|
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
|
mod = G.create_module(
|
|
matiere_id=mat["matiere_id"],
|
|
code="TSM1",
|
|
coefficient=1.0,
|
|
titre="module test",
|
|
ue_id=ue["ue_id"], # faiblesse de l'API
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
)
|
|
|
|
# --- Mise place d'un semestre
|
|
sem = G.create_formsemestre(
|
|
formation_id=f["formation_id"],
|
|
semestre_id=1,
|
|
date_debut="01/01/2020",
|
|
date_fin="30/06/2020",
|
|
)
|
|
|
|
mi = G.create_moduleimpl(
|
|
module_id=mod["module_id"],
|
|
formsemestre_id=sem["formsemestre_id"],
|
|
responsable_id="bach",
|
|
)
|
|
|
|
# --- Inscription des étudiants
|
|
for etud in etuds:
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
# --- Creation évaluation
|
|
e = G.create_evaluation(
|
|
moduleimpl_id=mi["moduleimpl_id"],
|
|
jour="01/01/2020",
|
|
description="evaluation test",
|
|
coefficient=1.0,
|
|
)
|
|
|
|
# --- Saisie notes
|
|
for etud in etuds:
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
evaluation=e, etud=etud, note=float(random.randint(0, 20))
|
|
)
|
|
|
|
# --- Saisie absences
|
|
etudid = etuds[0]["etudid"]
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
|
context.Absences,
|
|
"15/01/2020",
|
|
"18/01/2020",
|
|
demijournee=2,
|
|
etudid=etudid,
|
|
REQUEST=REQUEST,
|
|
)
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
|
context.Absences,
|
|
"17/01/2020",
|
|
"18/01/2020",
|
|
demijournee=2,
|
|
etudid=etudid,
|
|
REQUEST=REQUEST,
|
|
)
|
|
|
|
a = sco_abs.getAbsSemEtud(context.Absences, sem, etudid)
|
|
assert a.CountAbs() == 3
|
|
assert a.CountAbsJust() == 1
|