doc de create_test_api_database amélioré + ajout du code nip et ine lors de la création des etud + test dept et etu presque fini

This commit is contained in:
leonard_montalbano 2022-04-15 15:57:44 +02:00
parent 2000565d82
commit 6aba3a3ccd
6 changed files with 73 additions and 38 deletions

View File

@ -123,19 +123,32 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
"prenom": "JACQUES" "prenom": "JACQUES"
} }
""" """
etu = [] # etu = []
if etudid is not None: # Si route etudid if etudid is None:
# Récupération de l'étudiant if nip is None: # si ine
etu = models.Identite.query.filter_by(code_ine=str(ine)).first()
else: # si nip
etu = models.Identite.query.filter_by(code_nip=str(nip)).first()
else: # si etudid
etu = models.Identite.query.filter_by(id=etudid).first() etu = models.Identite.query.filter_by(id=etudid).first()
if nip is not None: # Si route nip
# Récupération de l'étudiant
etu = models.Identite.query.filter_by(code_nip=nip).first()
if ine is not None: # Si route ine
# Récupération de l'étudiant # if etudid is not None: # Si route etudid
etu = models.Identite.query.filter_by(code_ine=ine).first() # # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(id=etudid).first()
#
# if nip is not None: # Si route nip
# # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(code_nip=str(nip)).first()
#
# breakpoint()
#
# if ine is not None: # Si route ine
# # Récupération de l'étudiant
# etu = models.Identite.query.filter_by(code_ine=str(ine)).first()
# Mise en forme des données # Mise en forme des données
data = etu.to_dict_bul(include_urls=False) data = etu.to_dict_bul(include_urls=False)
@ -321,9 +334,10 @@ def etudiant_groups(formsemestre_id: int, etudid: int = None, nip: int = None, i
# Récupération du formsemestre # Récupération du formsemestre
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first() sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
#breakpoint()
try: try:
# Utilisation de la fonction get_etud_groups # Utilisation de la fonction get_etud_groups
data = get_etud_groups(etudid, sem.to_dict()) data = get_etud_groups(etudid, sem.id)
except ValueError: except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel") return error_response(409, message="La requête ne peut être traitée en létat actuel")

View File

@ -4,7 +4,6 @@ from flask import jsonify
from app import models from app import models
from app.api import bp from app.api import bp
from app.api.errors import error_response from app.api.errors import error_response
from app.decorators import permission_required
from app.api.auth import token_auth, token_permission_required from app.api.auth import token_auth, token_permission_required
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission

View File

@ -75,9 +75,9 @@ def test_referenciel_competences():
# # semestre_index # # semestre_index
def test_semestre_index(): #XXX TODO pour Seb # def test_semestre_index(): #XXX TODO pour Seb
r = requests.get( # r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme", # SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
headers=HEADERS, verify=CHECK_CERTIFICATE # headers=HEADERS, verify=CHECK_CERTIFICATE
) # )
assert r.status_code == 200 # assert r.status_code == 200

View File

@ -22,6 +22,7 @@ import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# etudiants # etudiants
def test_etudiants(): def test_etudiants():
r = requests.get( r = requests.get(
@ -46,6 +47,20 @@ def test_etudiants():
"nom", "nom",
"prenom", "prenom",
"nomprenom", "nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"id",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
] ]
fields_OK = True fields_OK = True
@ -66,7 +81,7 @@ def test_etudiants_courant(): #XXX TODO pour Seb
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 0 assert len(r.json()) == 16
# etudiant # etudiant
@ -77,18 +92,21 @@ def test_etudiant(): #XXX TODO pour Seb
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 10 assert len(r.json()) == 24
# r = requests.get( r = requests.get(
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>", SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
# headers=HEADERS, verify=CHECK_CERTIFICATE headers=HEADERS, verify=CHECK_CERTIFICATE
# ) )
# assert r.status_code == 200 assert r.status_code == 200
# r = requests.get( assert len(r.json()) == 24
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>",
# headers=HEADERS, verify=CHECK_CERTIFICATE r = requests.get(
# ) SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
# assert r.status_code == 200 headers=HEADERS, verify=CHECK_CERTIFICATE
)
assert r.status_code == 200
assert len(r.json()) == 24
# etudiant_formsemestres # etudiant_formsemestres

View File

@ -24,7 +24,7 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# formsemestre # formsemestre
def test_formsemestre(): def test_formsemestre():
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/<int:formsemestre_id>", SCODOC_URL + "/ScoDoc/api/formations/formsemestre/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -35,7 +35,7 @@ def test_formsemestre():
def test_etudiant_bulletin(): #XXX TODO pour Seb def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin", + "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/etudid/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -43,7 +43,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin", + "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/nip/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -51,7 +51,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL
+ "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin", + "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/ine/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -61,7 +61,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
# bulletins # bulletins
def test_bulletins(): def test_bulletins():
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/bulletins", SCODOC_URL + "/ScoDoc/api/formsemestre/1/bulletins",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -71,7 +71,7 @@ def test_bulletins():
# jury # jury
def test_jury(): def test_jury():
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/jury", SCODOC_URL + "/ScoDoc/api/formsemestre/1/jury",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )

View File

@ -86,6 +86,10 @@ def create_fake_etud(dept):
etud = models.Identite(civilite=civilite, nom=nom, prenom=prenom, dept_id=dept.id) etud = models.Identite(civilite=civilite, nom=nom, prenom=prenom, dept_id=dept.id)
db.session.add(etud) db.session.add(etud)
db.session.commit() db.session.commit()
etud.code_nip = etud.id
etud.code_ine = etud.id
db.session.add(etud)
db.session.commit()
adresse = models.Adresse( adresse = models.Adresse(
etudid=etud.id, email=f"{etud.prenom}.{etud.nom}@example.com" etudid=etud.id, email=f"{etud.prenom}.{etud.nom}@example.com"
) )