ScoDoc-PE/scotests/test_demissions.py

102 lines
2.7 KiB
Python
Raw Normal View History

2021-01-29 07:36:26 +01:00
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Test inscriptions / demissions / affichages notes
- Création 2 étudiants, puis formation en 1 semestre.
- Saisie de 2 notes
- Demission d'un étudiant
- bulletins
Utiliser comme:
scotests/scointeractive.sh -r TEST00 scotests/test_demissions.py
"""
2021-02-16 15:16:01 +01:00
import datetime
import re
import json
2021-01-29 07:36:26 +01:00
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
2021-01-29 07:36:26 +01:00
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
import sco_utils
import sco_bulletins
2021-02-16 15:16:01 +01:00
G = sco_fake_gen.ScoFake(context.Notes)
2021-01-29 07:36:26 +01:00
G.verbose = False
2021-02-16 15:16:01 +01:00
nb_etuds = 10
2021-01-29 07:36:26 +01:00
# --- Création d'étudiants
2021-02-16 15:16:01 +01:00
etuds = [G.create_etud(code_nip=None) for _ in range(nb_etuds)]
2021-01-29 07:36:26 +01:00
# --- Mise en place formation
form, ue_list, mod_list = G.setup_formation(
nb_semestre=1, titre="Essai 1", acronyme="ESS01"
)
# Mise en place semestre
sem, eval_list = G.setup_formsemestre(
form,
mod_list,
semestre_id=1,
date_debut="01/01/2021",
date_fin="31/12/2021",
titre="Essai démissions",
)
# Inscriptions
for etud in etuds:
G.inscrit_etudiant(sem, etud)
# Notes
G.set_etud_notes_sem(sem, eval_list, etuds)
# Bulletins
bul = sco_bulletins.formsemestre_bulletinetud_dict(
context.Notes, sem["formsemestre_id"], etuds[0]["etudid"]
)
print(bul["moy_gen"])
assert bul["ins"][0]["etat"] == "I"
# Démission:
context.doDemEtudiant(
etuds[0]["etudid"], sem["formsemestre_id"], event_date="15/12/2021"
)
bul = sco_bulletins.formsemestre_bulletinetud_dict(
context.Notes, sem["formsemestre_id"], etuds[0]["etudid"]
)
print(bul["moy_gen"])
assert bul["moy_gen"] == "NA"
assert bul["ins"][0]["etat"] == "D"
2021-02-16 15:16:01 +01:00
# ------------ Billets d'absences
etud = etuds[1] # non demissionnaire
d = sem["date_debut_iso"]
d_beg = datetime.datetime(*[int(x) for x in d.split("-")])
d_end = d_beg + datetime.timedelta(2)
description = "billet test 0"
x = context.Absences.AddBilletAbsence(
d_beg.isoformat(),
d_end.isoformat(),
description=description,
etudid=etud["etudid"],
REQUEST=REQUEST,
)
#
billet_id = re.search(r"billet_id value=\"([A-Z0-9]+)\"", x).group(1)
context.Absences.deleteBilletAbsence(billet_id, REQUEST=REQUEST, dialog_confirmed=True)
j = context.Absences.listeBilletsEtud(
etudid=etud["etudid"], REQUEST=REQUEST, format="json"
)
assert len(json.loads(j)) == 0
x = context.Absences.AddBilletAbsence(
d_beg.isoformat(),
d_end.isoformat(),
description=description,
etudid=etud["etudid"],
REQUEST=REQUEST,
)
j = context.Absences.listeBilletsEtud(
etudid=etud["etudid"], REQUEST=REQUEST, format="json"
)
assert json.loads(j)[0]["description"] == description