forked from ScoDoc/DocScoDoc
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:
parent
2000565d82
commit
6aba3a3ccd
@ -123,19 +123,32 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
||||
"prenom": "JACQUES"
|
||||
}
|
||||
"""
|
||||
etu = []
|
||||
# etu = []
|
||||
|
||||
if etudid is not None: # Si route etudid
|
||||
# Récupération de l'étudiant
|
||||
if etudid is None:
|
||||
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()
|
||||
|
||||
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
|
||||
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||
|
||||
# if etudid is not None: # Si route etudid
|
||||
# # 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
|
||||
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
|
||||
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
||||
#breakpoint()
|
||||
try:
|
||||
# Utilisation de la fonction get_etud_groups
|
||||
data = get_etud_groups(etudid, sem.to_dict())
|
||||
data = get_etud_groups(etudid, sem.id)
|
||||
except ValueError:
|
||||
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||
|
||||
|
@ -4,7 +4,6 @@ from flask import jsonify
|
||||
from app import models
|
||||
from app.api import bp
|
||||
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.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
@ -75,9 +75,9 @@ def test_referenciel_competences():
|
||||
|
||||
|
||||
# # semestre_index
|
||||
def test_semestre_index(): #XXX TODO pour Seb
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
# def test_semestre_index(): #XXX TODO pour Seb
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
|
||||
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
|
@ -22,6 +22,7 @@ import requests
|
||||
|
||||
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||
|
||||
|
||||
# etudiants
|
||||
def test_etudiants():
|
||||
r = requests.get(
|
||||
@ -46,6 +47,20 @@ def test_etudiants():
|
||||
"nom",
|
||||
"prenom",
|
||||
"nomprenom",
|
||||
"lieu_naissance",
|
||||
"dept_naissance",
|
||||
"nationalite",
|
||||
"boursier",
|
||||
"id",
|
||||
"domicile",
|
||||
"villedomicile",
|
||||
"telephone",
|
||||
"fax",
|
||||
"description",
|
||||
"codepostaldomicile",
|
||||
"paysdomicile",
|
||||
"telephonemobile",
|
||||
"typeadresse",
|
||||
]
|
||||
|
||||
fields_OK = True
|
||||
@ -66,7 +81,7 @@ def test_etudiants_courant(): #XXX TODO pour Seb
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 0
|
||||
assert len(r.json()) == 16
|
||||
|
||||
|
||||
# etudiant
|
||||
@ -77,18 +92,21 @@ def test_etudiant(): #XXX TODO pour Seb
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 10
|
||||
assert len(r.json()) == 24
|
||||
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>",
|
||||
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>",
|
||||
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 24
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 24
|
||||
|
||||
|
||||
# etudiant_formsemestres
|
||||
|
@ -24,7 +24,7 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||
# formsemestre
|
||||
def test_formsemestre():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/<int:formsemestre_id>",
|
||||
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/1",
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
@ -35,7 +35,7 @@ def test_formsemestre():
|
||||
def test_etudiant_bulletin(): #XXX TODO pour Seb
|
||||
r = requests.get(
|
||||
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,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
@ -43,7 +43,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
|
||||
|
||||
r = requests.get(
|
||||
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,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
@ -51,7 +51,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
|
||||
|
||||
r = requests.get(
|
||||
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,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
@ -61,7 +61,7 @@ def test_etudiant_bulletin(): #XXX TODO pour Seb
|
||||
# bulletins
|
||||
def test_bulletins():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/bulletins",
|
||||
SCODOC_URL + "/ScoDoc/api/formsemestre/1/bulletins",
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
@ -71,7 +71,7 @@ def test_bulletins():
|
||||
# jury
|
||||
def test_jury():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/jury",
|
||||
SCODOC_URL + "/ScoDoc/api/formsemestre/1/jury",
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
|
@ -86,6 +86,10 @@ def create_fake_etud(dept):
|
||||
etud = models.Identite(civilite=civilite, nom=nom, prenom=prenom, dept_id=dept.id)
|
||||
db.session.add(etud)
|
||||
db.session.commit()
|
||||
etud.code_nip = etud.id
|
||||
etud.code_ine = etud.id
|
||||
db.session.add(etud)
|
||||
db.session.commit()
|
||||
adresse = models.Adresse(
|
||||
etudid=etud.id, email=f"{etud.prenom}.{etud.nom}@example.com"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user