2022-03-09 16:52:07 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Test Logos
|
|
|
|
|
|
|
|
Utilisation :
|
|
|
|
créer les variables d'environnement: (indiquer les valeurs
|
|
|
|
pour le serveur ScoDoc que vous voulez interroger)
|
|
|
|
|
|
|
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
|
|
|
export SCODOC_USER="xxx"
|
|
|
|
export SCODOC_PASSWD="xxx"
|
|
|
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
|
|
|
|
|
|
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
|
|
|
|
|
|
|
Lancer :
|
|
|
|
pytest tests/api/test_api_etudiants.py
|
|
|
|
"""
|
2022-03-11 16:18:50 +01:00
|
|
|
from random import randint
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
import requests
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-15 15:57:44 +02:00
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
# # etudiants
|
|
|
|
# def test_etudiants():
|
|
|
|
#
|
|
|
|
# fields = [
|
|
|
|
# "civilite",
|
|
|
|
# "code_ine",
|
|
|
|
# "code_nip",
|
|
|
|
# "date_naissance",
|
|
|
|
# "email",
|
|
|
|
# "emailperso",
|
|
|
|
# "etudid",
|
|
|
|
# "nom",
|
|
|
|
# "prenom",
|
|
|
|
# "nomprenom",
|
|
|
|
# "lieu_naissance",
|
|
|
|
# "dept_naissance",
|
|
|
|
# "nationalite",
|
|
|
|
# "boursier",
|
|
|
|
# "id",
|
|
|
|
# "domicile",
|
|
|
|
# "villedomicile",
|
|
|
|
# "telephone",
|
|
|
|
# "fax",
|
|
|
|
# "description",
|
|
|
|
# "codepostaldomicile",
|
|
|
|
# "paysdomicile",
|
|
|
|
# "telephonemobile",
|
|
|
|
# "typeadresse",
|
|
|
|
# ]
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiants",
|
|
|
|
# headers=HEADERS,
|
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
# assert len(r.json()) == 16
|
|
|
|
#
|
|
|
|
# # Choisis aléatoirement un étudiant dans la liste des étudiants
|
|
|
|
# etu = r.json()[randint(0, len(r.json())) - 1]
|
|
|
|
#
|
|
|
|
# fields_OK = True
|
|
|
|
#
|
|
|
|
# # Vérifie si tous les champs sont bien présents
|
|
|
|
# for field in etu:
|
|
|
|
# if field not in fields:
|
|
|
|
# fields_OK = False
|
|
|
|
#
|
|
|
|
# assert fields_OK is True
|
2022-03-11 16:18:50 +01:00
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
# etudiants_courant
|
2022-04-15 15:57:44 +02:00
|
|
|
def test_etudiants_courant(): # XXX TODO pour Seb
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
fields = [
|
|
|
|
"civilite",
|
|
|
|
"code_ine",
|
|
|
|
"code_nip",
|
|
|
|
"date_naissance",
|
|
|
|
"email",
|
|
|
|
"emailperso",
|
|
|
|
"etudid",
|
|
|
|
"nom",
|
|
|
|
"prenom",
|
|
|
|
"nomprenom",
|
|
|
|
"lieu_naissance",
|
|
|
|
"dept_naissance",
|
|
|
|
"nationalite",
|
|
|
|
"boursier",
|
|
|
|
"id",
|
|
|
|
"domicile",
|
|
|
|
"villedomicile",
|
|
|
|
"telephone",
|
|
|
|
"fax",
|
|
|
|
"description",
|
|
|
|
"codepostaldomicile",
|
|
|
|
"paysdomicile",
|
|
|
|
"telephonemobile",
|
|
|
|
"typeadresse",
|
|
|
|
]
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-03-11 16:18:50 +01:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
|
2022-04-13 12:39:10 +02:00
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2022-03-11 16:18:50 +01:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-04-15 15:57:44 +02:00
|
|
|
assert len(r.json()) == 16
|
2022-03-11 16:18:50 +01:00
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
|
|
|
etu = r.json()[randint(0, len(r.json())) - 1]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in etu:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
# etudiant
|
2022-04-15 15:57:44 +02:00
|
|
|
def test_etudiant(): # XXX TODO pour Seb
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
fields = [
|
|
|
|
"civilite",
|
|
|
|
"code_ine",
|
|
|
|
"code_nip",
|
|
|
|
"date_naissance",
|
|
|
|
"email",
|
|
|
|
"emailperso",
|
|
|
|
"etudid",
|
|
|
|
"nom",
|
|
|
|
"prenom",
|
|
|
|
"nomprenom",
|
|
|
|
"lieu_naissance",
|
|
|
|
"dept_naissance",
|
|
|
|
"nationalite",
|
|
|
|
"boursier",
|
|
|
|
"id",
|
|
|
|
"domicile",
|
|
|
|
"villedomicile",
|
|
|
|
"telephone",
|
|
|
|
"fax",
|
|
|
|
"description",
|
|
|
|
"codepostaldomicile",
|
|
|
|
"paysdomicile",
|
|
|
|
"telephonemobile",
|
|
|
|
"typeadresse",
|
|
|
|
]
|
|
|
|
|
|
|
|
######### Test etudid #########
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-03-11 16:18:50 +01:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1",
|
2022-04-13 12:39:10 +02:00
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2022-03-11 16:18:50 +01:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-04-15 15:57:44 +02:00
|
|
|
assert len(r.json()) == 24
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
etu = r.json()
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in etu:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code nip #########
|
|
|
|
|
2022-04-15 15:57:44 +02:00
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-15 15:57:44 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 24
|
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
etu = r.json()
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in etu:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code ine #########
|
|
|
|
|
2022-04-15 15:57:44 +02:00
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-15 15:57:44 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 24
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
etu = r.json()
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in etu:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
# etudiant_formsemestres
|
2022-04-15 15:57:44 +02:00
|
|
|
def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
fields = [
|
|
|
|
"date_fin",
|
|
|
|
"resp_can_edit",
|
|
|
|
"dept_id",
|
|
|
|
"etat",
|
|
|
|
"resp_can_change_ens",
|
|
|
|
"id",
|
|
|
|
"modalite",
|
|
|
|
"ens_can_edit_eval",
|
|
|
|
"formation_id",
|
|
|
|
"gestion_compensation",
|
|
|
|
"elt_sem_apo",
|
|
|
|
"semestre_id",
|
|
|
|
"bul_hide_xml",
|
|
|
|
"elt_annee_apo",
|
|
|
|
"titre",
|
|
|
|
"block_moyennes",
|
|
|
|
"scodoc7_id",
|
|
|
|
"date_debut",
|
|
|
|
"gestion_semestrielle",
|
|
|
|
"bul_bgcolor",
|
|
|
|
"formsemestre_id",
|
|
|
|
"titre_num",
|
|
|
|
"date_debut_iso",
|
|
|
|
"date_fin_iso",
|
|
|
|
"responsables",
|
|
|
|
]
|
|
|
|
|
|
|
|
######### Test etudid #########
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-03-11 16:18:50 +01:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestres",
|
2022-04-13 12:39:10 +02:00
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2022-03-11 16:18:50 +01:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-03-11 16:18:50 +01:00
|
|
|
assert len(r.json()) == 1
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
formsemestre = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in formsemestre:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code nip #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestres",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 1
|
|
|
|
|
|
|
|
formsemestre = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in formsemestre:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code ine #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestres",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 1
|
|
|
|
|
|
|
|
formsemestre = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in formsemestre:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
# etudiant_bulletin_semestre
|
2022-04-20 15:50:02 +02:00
|
|
|
def test_etudiant_bulletin_semestre():
|
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
# fields = [
|
|
|
|
# "etudid",
|
|
|
|
# "formsemestre_id",
|
|
|
|
# "date",
|
|
|
|
# "publie",
|
|
|
|
# "etapes",
|
|
|
|
# "etudiant",
|
|
|
|
# "note",
|
|
|
|
# "rang",
|
|
|
|
# "rang_group",
|
|
|
|
# "note_max",
|
|
|
|
# "bonus_sport_culture",
|
|
|
|
# "ue",
|
|
|
|
# "ue_capitalisee",
|
|
|
|
# "absences",
|
|
|
|
# "appreciation",
|
|
|
|
# ]
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
######### Test etudid #########
|
|
|
|
|
|
|
|
r = requests.get(
|
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
2022-04-26 17:12:30 +02:00
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2022-04-20 15:50:02 +02:00
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
2022-04-26 17:12:30 +02:00
|
|
|
assert len(r.json()) == 13
|
|
|
|
|
|
|
|
# bulletin = r.json()
|
|
|
|
#
|
|
|
|
# fields_OK = True
|
|
|
|
#
|
|
|
|
# # Vérifie si tous les champs sont bien présents
|
|
|
|
# for field in bulletin:
|
|
|
|
# if field not in fields:
|
|
|
|
# fields_OK = False
|
|
|
|
#
|
|
|
|
# assert fields_OK is True
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
######### Test code nip #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestre/1/bulletin",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
2022-04-26 17:12:30 +02:00
|
|
|
assert len(r.json()) == 13
|
|
|
|
|
|
|
|
# bulletin = r.json()
|
|
|
|
#
|
|
|
|
# fields_OK = True
|
|
|
|
#
|
|
|
|
# # Vérifie si tous les champs sont bien présents
|
|
|
|
# for field in bulletin:
|
|
|
|
# if field not in fields:
|
|
|
|
# fields_OK = False
|
|
|
|
#
|
|
|
|
# assert fields_OK is True
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
######### Test code ine #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestre/1/bulletin",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
2022-04-26 17:12:30 +02:00
|
|
|
assert len(r.json()) == 13
|
2022-04-20 15:50:02 +02:00
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
# bulletin = r.json()
|
|
|
|
#
|
|
|
|
# fields_OK = True
|
|
|
|
#
|
|
|
|
# # Vérifie si tous les champs sont bien présents
|
|
|
|
# for field in bulletin:
|
|
|
|
# if field not in fields:
|
|
|
|
# fields_OK = False
|
|
|
|
#
|
|
|
|
# assert fields_OK is True
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# etudiant_groups
|
2022-03-10 17:43:12 +01:00
|
|
|
def test_etudiant_groups():
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
fields = [
|
|
|
|
"partition_id",
|
|
|
|
"id",
|
|
|
|
"formsemestre_id",
|
|
|
|
"partition_name",
|
|
|
|
"numero",
|
|
|
|
"bul_show_rank",
|
|
|
|
"show_in_lists",
|
|
|
|
"group_id",
|
|
|
|
"group_name",
|
2022-04-26 17:12:30 +02:00
|
|
|
]
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
######### Test etudid #########
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-03-11 16:18:50 +01:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/semestre/1/groups",
|
2022-04-13 12:39:10 +02:00
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2022-03-11 16:18:50 +01:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-03-11 16:18:50 +01:00
|
|
|
assert len(r.json()) == 1
|
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
groups = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in groups:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code nip #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/semestre/1/groups",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 1
|
|
|
|
|
|
|
|
groups = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in groups:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|
|
|
|
|
|
|
|
######### Test code ine #########
|
|
|
|
|
|
|
|
r = requests.get(
|
2022-04-26 17:12:30 +02:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/semestre/1/groups",
|
|
|
|
headers=HEADERS,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
assert r.status_code == 200
|
|
|
|
assert len(r.json()) == 1
|
|
|
|
|
|
|
|
groups = r.json()[0]
|
|
|
|
|
|
|
|
fields_OK = True
|
|
|
|
|
|
|
|
# Vérifie si tous les champs sont bien présents
|
|
|
|
for field in groups:
|
|
|
|
if field not in fields:
|
|
|
|
fields_OK = False
|
|
|
|
|
|
|
|
assert fields_OK is True
|