TestsScoDoc7API/scotests/test_basic.py

98 lines
2.4 KiB
Python
Raw Normal View History

2020-12-26 00:11:55 +01:00
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Test de base de ScoDoc
2020-12-26 00:11:55 +01:00
Création 10 étudiants, formation, semestre, inscription etudiant, creation 1 evaluation, saisie 10 notes.
2020-12-26 00:11:55 +01:00
Utiliser comme:
scotests/scointeractive.sh -r TEST00 scotests/test_basic.py
"""
2020-12-27 13:45:24 +01:00
import random
2021-02-16 15:16:01 +01:00
# 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
2020-12-27 13:45:24 +01:00
import sco_utils
2021-02-04 23:16:18 +01:00
import sco_abs
import sco_abs_views
2020-12-26 00:11:55 +01:00
2021-02-16 15:16:01 +01:00
G = sco_fake_gen.ScoFake(context.Notes)
2020-12-27 13:45:24 +01:00
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,
)
2020-12-26 00:11:55 +01:00
2020-12-27 13:45:24 +01:00
# --- 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))
)
2021-02-04 23:16:18 +01:00
# --- 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