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-03-09 16:52:07 +01:00
|
|
|
# etudiants
|
2022-03-10 17:43:12 +01:00
|
|
|
def test_etudiants():
|
|
|
|
r = requests.get(
|
2022-03-11 16:18:50 +01:00
|
|
|
SCODOC_URL + "/ScoDoc/api/etudiants",
|
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()) == 16
|
|
|
|
|
|
|
|
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
2022-04-13 12:39:10 +02:00
|
|
|
etu = r.json()[randint(0, len(r.json())) - 1]
|
|
|
|
|
|
|
|
fields = [
|
|
|
|
"civilite",
|
|
|
|
"code_ine",
|
|
|
|
"code_nip",
|
|
|
|
"date_naissance",
|
|
|
|
"email",
|
|
|
|
"emailperso",
|
|
|
|
"etudid",
|
|
|
|
"nom",
|
|
|
|
"prenom",
|
|
|
|
"nomprenom",
|
2022-04-15 15:57:44 +02:00
|
|
|
"lieu_naissance",
|
|
|
|
"dept_naissance",
|
|
|
|
"nationalite",
|
|
|
|
"boursier",
|
|
|
|
"id",
|
|
|
|
"domicile",
|
|
|
|
"villedomicile",
|
|
|
|
"telephone",
|
|
|
|
"fax",
|
|
|
|
"description",
|
|
|
|
"codepostaldomicile",
|
|
|
|
"paysdomicile",
|
|
|
|
"telephonemobile",
|
|
|
|
"typeadresse",
|
2022-04-13 12:39:10 +02:00
|
|
|
]
|
2022-03-11 16:18:50 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
# etudiants_courant
|
2022-04-15 15:57:44 +02:00
|
|
|
def test_etudiants_courant(): # XXX TODO pour Seb
|
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-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
# etudiant
|
2022-04-15 15:57:44 +02:00
|
|
|
def test_etudiant(): # XXX TODO pour Seb
|
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-15 15:57:44 +02:00
|
|
|
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
|
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-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
|
|
|
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestres",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/formsemestres",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# etudiant_bulletin_semestre
|
2022-03-11 16:18:50 +01:00
|
|
|
# def test_etudiant_bulletin_semestre():
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
# assert len(r.json()) == 1
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
2022-03-09 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# etudiant_groups
|
2022-03-10 17:43:12 +01:00
|
|
|
def test_etudiant_groups():
|
|
|
|
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-03-10 17:43:12 +01:00
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/semestre/<int:formsemestre_id>/groups",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/semestre/<int:formsemestre_id>/groups",
|
|
|
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
|
|
|
# )
|
2022-03-11 16:18:50 +01:00
|
|
|
# assert r.status_code == 200
|