From f04265c78e2a06bd7aecc11b41c32abc94b6ba41 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Thu, 2 Jun 2022 16:18:47 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20de=20notes=20aux=20=C3=A9valuations=20d?= =?UTF-8?q?ans=20la=20cr=C3=A9ation=20de=20la=20fakedatabase=20+=20d=C3=A9?= =?UTF-8?q?but=20tests=20unitaires=20etat=5Fevals?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/api/test_api_formsemestre.py | 38 +++++++++++++++++++ .../fakedatabase/create_test_api_database.py | 27 ++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index bdcf7e93e..956992b9f 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -131,3 +131,41 @@ def test_formsemestre_programme(api_headers): assert verify_fields(modules[0], MODIMPL_FIELDS) assert verify_fields(ressource, MODIMPL_FIELDS) assert verify_fields(sae, MODIMPL_FIELDS) + + +# def test_formsemestre_etudiants(api_headers): +# """ +# Route: /formsemestre//etudiants, /formsemestre//etudiants/demissionnaires, /formsemestre//etudiants/defaillants +# """ +# r = requests.get( +# API_URL + "/formsemestre//etudiants", +# headers=api_headers, +# verify=CHECK_CERTIFICATE, +# ) +# assert r.status_code == 200 +# +# r = requests.get( +# API_URL + "/formsemestre//etudiants/demissionnaires", +# headers=api_headers, +# verify=CHECK_CERTIFICATE, +# ) +# assert r.status_code == 200 +# +# r = requests.get( +# API_URL + "/formsemestre//etudiants/defaillants", +# headers=api_headers, +# verify=CHECK_CERTIFICATE, +# ) +# assert r.status_code == 200 + + +def test_etat_evals(api_headers): + """ + Route : /formsemestre//etat_evals + """ + r = requests.get( + API_URL + "/formsemestre/1/etat_evals", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 200 diff --git a/tools/fakedatabase/create_test_api_database.py b/tools/fakedatabase/create_test_api_database.py index bfe4800e2..3744fc100 100644 --- a/tools/fakedatabase/create_test_api_database.py +++ b/tools/fakedatabase/create_test_api_database.py @@ -28,7 +28,7 @@ import sys from app.auth.models import Role, User 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.scodoc import ( sco_cache, @@ -38,6 +38,7 @@ from app.scodoc import ( sco_groups, ) from app.scodoc.sco_permissions import Permission +from app.scodoc.sco_saisie_notes import notes_add from tools.fakeportal.gen_nomprenoms import nomprenom random.seed(12345678) # tests reproductibles @@ -188,6 +189,29 @@ def create_evaluations(formsemestre: FormSemestre): 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(): """Appelé par la commande `flask init-test-database` @@ -201,6 +225,7 @@ def init_test_database(): formsemestre = create_formsemestre(formation, user_lecteur) create_evaluations(formsemestre) inscrit_etudiants(etuds, formsemestre) + saisie_note_evaluations(formsemestre, user_lecteur) # à compléter # - groupes # - absences