ajout de notes aux évaluations dans la création de la fakedatabase + début tests unitaires etat_evals

This commit is contained in:
leonard_montalbano 2022-06-02 16:18:47 +02:00
parent 36bfd9ecad
commit f04265c78e
2 changed files with 64 additions and 1 deletions

View File

@ -131,3 +131,41 @@ def test_formsemestre_programme(api_headers):
assert verify_fields(modules[0], MODIMPL_FIELDS) assert verify_fields(modules[0], MODIMPL_FIELDS)
assert verify_fields(ressource, MODIMPL_FIELDS) assert verify_fields(ressource, MODIMPL_FIELDS)
assert verify_fields(sae, MODIMPL_FIELDS) assert verify_fields(sae, MODIMPL_FIELDS)
# def test_formsemestre_etudiants(api_headers):
# """
# Route: /formsemestre/<int:formsemestre_id>/etudiants, /formsemestre/<int:formsemestre_id>/etudiants/demissionnaires, /formsemestre/<int:formsemestre_id>/etudiants/defaillants
# """
# r = requests.get(
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# r = requests.get(
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# r = requests.get(
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
def test_etat_evals(api_headers):
"""
Route : /formsemestre/<int:formsemestre_id>/etat_evals
"""
r = requests.get(
API_URL + "/formsemestre/1/etat_evals",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200

View File

@ -28,7 +28,7 @@ import sys
from app.auth.models import Role, User from app.auth.models import Role, User
from app import models from app import models
from app.models import Departement, Formation, FormSemestre, Identite from app.models import Departement, Formation, FormSemestre, Identite, ModuleImpl
from app import db from app import db
from app.scodoc import ( from app.scodoc import (
sco_cache, sco_cache,
@ -38,6 +38,7 @@ from app.scodoc import (
sco_groups, sco_groups,
) )
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_saisie_notes import notes_add
from tools.fakeportal.gen_nomprenoms import nomprenom from tools.fakeportal.gen_nomprenoms import nomprenom
random.seed(12345678) # tests reproductibles random.seed(12345678) # tests reproductibles
@ -188,6 +189,29 @@ def create_evaluations(formsemestre: FormSemestre):
evaluation_id = sco_evaluation_db.do_evaluation_create(**args) evaluation_id = sco_evaluation_db.do_evaluation_create(**args)
def saisie_note_evaluations(formsemestre: FormSemestre, user: User):
"""
Saisie les notes des evaluations d'un semestre
"""
# Récupération des id des étudiants du semestre
list_etudids = [etud.id for etud in formsemestre.etuds]
list_ues = formsemestre.query_ues()
def create_list_etudid_random_notes():
"""
Retourne une liste de tuple (etudid, note_random)
"""
return [(etudid, random.uniform(0.0, 20.0)) for etudid in list_etudids]
for ue in list_ues:
mods = ue.modules
for mod in mods:
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
for evaluation in moduleimpl.evaluations:
notes = create_list_etudid_random_notes()
notes_add(user, evaluation.id, notes)
def init_test_database(): def init_test_database():
"""Appelé par la commande `flask init-test-database` """Appelé par la commande `flask init-test-database`
@ -201,6 +225,7 @@ def init_test_database():
formsemestre = create_formsemestre(formation, user_lecteur) formsemestre = create_formsemestre(formation, user_lecteur)
create_evaluations(formsemestre) create_evaluations(formsemestre)
inscrit_etudiants(etuds, formsemestre) inscrit_etudiants(etuds, formsemestre)
saisie_note_evaluations(formsemestre, user_lecteur)
# à compléter # à compléter
# - groupes # - groupes
# - absences # - absences