ajout tests unitaires formsemestre_etudiants

This commit is contained in:
leonard_montalbano 2022-06-22 16:26:50 +02:00
parent cacf437ef7
commit 938090bd32
2 changed files with 154 additions and 24 deletions

View File

@ -26,6 +26,7 @@ from tests.api.tools_test_api import (
verify_fields, verify_fields,
EVAL_FIELDS, EVAL_FIELDS,
SAISIE_NOTES_FIELDS, SAISIE_NOTES_FIELDS,
FORMSEMESTRE_ETUS_FIELDS,
) )
from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS
@ -81,30 +82,135 @@ def test_bulletins(api_headers):
# assert r.status_code == 200 # assert r.status_code == 200
# def test_formsemestre_etudiants(api_headers): def test_formsemestre_etudiants(api_headers):
# """ """
# Route: /formsemestre/<int:formsemestre_id>/etudiants, /formsemestre/<int:formsemestre_id>/etudiants/demissionnaires, /formsemestre/<int:formsemestre_id>/etudiants/defaillants Route: /formsemestre/<int:formsemestre_id>/etudiants,
# """ /formsemestre/<int:formsemestre_id>/etudiants/demissionnaires,
# r = requests.get( /formsemestre/<int:formsemestre_id>/etudiants/defaillants
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants", """
# headers=api_headers, r = requests.get(
# verify=CHECK_CERTIFICATE, API_URL + "/formsemestre/1/etudiants",
# ) headers=api_headers,
# assert r.status_code == 200 verify=CHECK_CERTIFICATE,
# )
# r = requests.get( assert r.status_code == 200
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires", formsemestre_etus = r.json()
# headers=api_headers, assert isinstance(formsemestre_etus, list)
# verify=CHECK_CERTIFICATE, assert verify_fields(formsemestre_etus, FORMSEMESTRE_ETUS_FIELDS) is True
# ) for etu in formsemestre_etus:
# assert r.status_code == 200 assert isinstance(etu["id"], int)
# assert isinstance(etu["nip"], str)
# r = requests.get( assert isinstance(etu["ine"], str)
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants", assert isinstance(etu["nom"], str)
# headers=api_headers, assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
# verify=CHECK_CERTIFICATE, assert isinstance(etu["prenom"], str)
# ) assert isinstance(etu["civilite"], str)
# assert r.status_code == 200 assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
### demissionnaires ###
r_demissionnaires = requests.get(
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 isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
assert isinstance(etu["nom"], str)
assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["civilite"], str)
assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
### defaillants ###
r_defaillants = requests.get(
API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_defaillants.status_code == 200
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 isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
assert isinstance(etu["nom"], str)
assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["civilite"], str)
assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
assert r != r_demissionnaires != r_defaillants is True
### ERROR ###
id_formsemestre_inexistant = 265165689619851621685
r_error = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
r_error_demissionnaires = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/demissionnaires",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error_demissionnaires.status_code == 404
r_error_defaillants = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error_defaillants.status_code == 404
def test_formsemestre_programme(api_headers): def test_formsemestre_programme(api_headers):

View File

@ -534,3 +534,27 @@ ABSENCES_FIELDS = {
} }
ABSENCES_GROUP_ETAT_FIELDS = {"etudid", "list_abs"} ABSENCES_GROUP_ETAT_FIELDS = {"etudid", "list_abs"}
FORMSEMESTRE_ETUS_FIELDS = {
"id",
"nip",
"ine",
"nom",
"nom_usuel",
"prenom",
"cvilite",
"groups",
}
FORMSEMESTRE_ETUS_GROUPS_FIELDS = {
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
"group_id",
"group_name",
}