forked from ScoDoc/DocScoDoc
96 lines
2.9 KiB
Python
96 lines
2.9 KiB
Python
|
# -*- mode: python -*-
|
||
|
# -*- coding: utf-8 -
|
||
|
|
||
|
""" Création de billet, utilisation de XMLgetBilletsEtud et suppression de billet """
|
||
|
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_abs_views
|
||
|
|
||
|
|
||
|
G = sco_fake_gen.ScoFake(context.Notes)
|
||
|
G.verbose = False
|
||
|
|
||
|
# --- 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/2021",
|
||
|
date_fin="30/06/2021",
|
||
|
)
|
||
|
|
||
|
mi = G.create_moduleimpl(
|
||
|
module_id=mod["module_id"],
|
||
|
formsemestre_id=sem["formsemestre_id"],
|
||
|
responsable_id="bach",
|
||
|
)
|
||
|
|
||
|
# --- Création d'un étudiant
|
||
|
etud = G.create_etud(code_nip=None)
|
||
|
G.inscrit_etudiant(sem, etud)
|
||
|
etudid=etud["etudid"]
|
||
|
|
||
|
# --- Création d'une absence
|
||
|
sco_abs_views.doSignaleAbsence(context.Absences, datedebut="22/01/2021", datefin="22/01/2021", demijournee=2, etudid=etudid, REQUEST=REQUEST)
|
||
|
|
||
|
# --- Création d'un billet
|
||
|
b1 = context.Absences.AddBilletAbsence(
|
||
|
begin="2021-01-22 00:00",
|
||
|
end="2021-01-22 23:59",
|
||
|
etudid=etudid,
|
||
|
description = "abs du 22",
|
||
|
justified=False,
|
||
|
code_nip=etud["code_nip"],
|
||
|
code_ine=etud["code_ine"],
|
||
|
REQUEST=REQUEST,
|
||
|
)
|
||
|
|
||
|
# --- XMLgetBilletEtud
|
||
|
|
||
|
xml_bi = context.Absences.XMLgetBilletsEtud(etudid=etudid, REQUEST=REQUEST)
|
||
|
print(1)
|
||
|
print(xml_bi)
|
||
|
print(1)
|
||
|
|
||
|
|
||
|
# --- Suppression d'un billet
|
||
|
li_bi = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||
|
load_li_bi = json.loads(li_bi)
|
||
|
|
||
|
_ = context.Absences.deleteBilletAbsence(load_li_bi[0]["billet_id"], REQUEST=REQUEST)
|
||
|
|
||
|
li_bi2 = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||
|
load_li_bi2 = json.loads(li_bi)
|
||
|
|
||
|
assert len(load_li_bi2) == 0
|
||
|
|
||
|
"""
|
||
|
Commentaire :
|
||
|
|
||
|
XMLgetBilletsEtud retourne une chaine vide
|
||
|
|
||
|
deleteBilletsEtud : erreur
|
||
|
File "/opt/scodoc/Products/ScoDoc/ZAbsences.py", line 1809, in deleteBilletAbsence
|
||
|
parameters={"billet_id": billet_id},
|
||
|
File "/opt/scodoc/Products/ScoDoc/ZScolar.py", line 2664, in confirmDialog
|
||
|
return self.sco_header(REQUEST) + "\n".join(H) + self.sco_footer(REQUEST)
|
||
|
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 223: ordinal not in range(128)
|
||
|
|
||
|
"""
|