Compare commits

..

No commits in common. "031dc409be4996ab9f8cc8630697f1c6f7b558c8" and "85e7818843a118c68058951428c551cc7585e96e" have entirely different histories.

3 changed files with 11 additions and 22 deletions

View File

@ -7,7 +7,6 @@ import app
from app import models
from app.api import bp
from app.api.auth import token_auth, token_permission_required
from app.api.errors import error_response
from app.comp import res_sem
from app.comp.moy_mod import ModuleImplResults
from app.comp.res_compat import NotesTableCompat
@ -92,13 +91,7 @@ def formsemestre_apo(etape_apo: str):
FormSemestreEtape.formsemestre_id == FormSemestre.id,
)
res = [formsemestre.to_dict() for formsemestre in formsemestres]
if len(res) == 0:
return error_response(
404, message="Aucun formsemestre trouvé avec cette étape apogée"
)
else:
return jsonify(res)
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])

View File

@ -144,12 +144,12 @@ def test_formsemestre_apo(api_headers):
### ERROR ###
etape_apo_inexistante = "aoefiaozidaoẑidjnoaiznjd"
r_error = requests.get(
r = requests.get(
f"{API_URL}/formsemestre/apo/{etape_apo_inexistante}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
assert r.status_code == 404
def test_bulletins(api_headers):
@ -180,17 +180,16 @@ def test_formsemestre_etudiants(api_headers):
/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires,
/formsemestre/<int:formsemestre_id>/etudiants/defaillants
"""
formsemestre_id = 1
r = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants",
API_URL + "/formsemestre/1/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
formsemestre_etus = r.json()
assert isinstance(formsemestre_etus, list)
assert verify_fields(formsemestre_etus, FORMSEMESTRE_ETUS_FIELDS) is True
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
@ -215,16 +214,15 @@ def test_formsemestre_etudiants(api_headers):
### demissionnaires ###
r_demissionnaires = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants/demissionnaires",
API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_demissionnaires.status_code == 200
formsemestre_etus = r_demissionnaires.json()
assert isinstance(formsemestre_etus, list)
assert verify_fields(formsemestre_etus, FORMSEMESTRE_ETUS_FIELDS) is True
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
@ -249,7 +247,7 @@ def test_formsemestre_etudiants(api_headers):
### defaillants ###
r_defaillants = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants/defaillants",
API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -257,8 +255,8 @@ def test_formsemestre_etudiants(api_headers):
formsemestre_etus = r_defaillants.json()
assert isinstance(formsemestre_etus, list)
assert verify_fields(formsemestre_etus, FORMSEMESTRE_ETUS_FIELDS) is True
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
@ -281,9 +279,7 @@ def test_formsemestre_etudiants(api_headers):
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
assert r.json() != r_demissionnaires.json()
assert r.json() != r_defaillants.json()
assert r_demissionnaires.json() != r_defaillants.json()
assert r != r_demissionnaires != r_defaillants is True
### ERROR ###
id_formsemestre_inexistant = 265165689619851621685

View File

@ -543,7 +543,7 @@ FORMSEMESTRE_ETUS_FIELDS = {
"nom",
"nom_usuel",
"prenom",
"civilite",
"cvilite",
"groups",
}