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_partitions.py
|
|
|
|
"""
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
import requests
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
2022-06-23 16:20:59 +02:00
|
|
|
from tests.api.tools_test_api import (
|
|
|
|
verify_fields,
|
|
|
|
PARTITIONS_FIELDS,
|
|
|
|
PARTITIONS_GROUPS_ETU_FIELDS,
|
|
|
|
)
|
2022-05-03 16:15:04 +02:00
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_partition(api_headers):
|
|
|
|
"""
|
2022-05-06 16:05:34 +02:00
|
|
|
Test 'partition'
|
|
|
|
|
|
|
|
Route :
|
|
|
|
- /partitions/<int:formsemestre_id>
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-06-23 16:20:59 +02:00
|
|
|
partition_id = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-06-23 16:20:59 +02:00
|
|
|
f"{API_URL}/partitions/{partition_id}",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-05-04 23:11:20 +02:00
|
|
|
partitions = r.json()
|
|
|
|
assert len(partitions) == 1
|
2022-06-23 16:20:59 +02:00
|
|
|
assert isinstance(partitions, list)
|
2022-05-04 23:11:20 +02:00
|
|
|
partition = partitions[0]
|
2022-06-23 16:20:59 +02:00
|
|
|
assert isinstance(partition, dict)
|
|
|
|
assert verify_fields(partition, PARTITIONS_FIELDS) is True
|
|
|
|
assert partition_id == partition["partition_id"]
|
|
|
|
|
|
|
|
assert isinstance(partition["partition_id"], int)
|
|
|
|
assert isinstance(partition["id"], int)
|
|
|
|
assert isinstance(partition["formsemestre_id"], int)
|
|
|
|
assert partition["partition_name"] is None or isinstance(
|
|
|
|
partition["partition_name"], str
|
|
|
|
)
|
|
|
|
assert isinstance(partition["numero"], int)
|
|
|
|
assert isinstance(partition["bul_show_rank"], bool)
|
|
|
|
assert isinstance(partition["show_in_lists"], bool)
|
2022-04-13 12:39:10 +02:00
|
|
|
|
2022-05-03 16:15:04 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_etud_in_group(api_headers):
|
|
|
|
"""
|
2022-05-06 16:05:34 +02:00
|
|
|
Test 'etud_in_group'
|
|
|
|
|
|
|
|
Routes :
|
2022-06-23 16:20:59 +02:00
|
|
|
- /partition/group/<int:group_id>
|
|
|
|
- /partition/group/<int:group_id>/etat/<string:etat>
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-06-23 16:20:59 +02:00
|
|
|
group_id = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-06-23 16:20:59 +02:00
|
|
|
f"{API_URL}/partition/group/{group_id}",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
2022-06-23 16:20:59 +02:00
|
|
|
assert isinstance(r.json(), list)
|
|
|
|
|
|
|
|
for etu in r.json():
|
|
|
|
assert verify_fields(etu, PARTITIONS_GROUPS_ETU_FIELDS)
|
|
|
|
assert isinstance(etu["etudid"], int)
|
|
|
|
assert isinstance(etu["id"], int)
|
|
|
|
assert isinstance(etu["dept_id"], int)
|
|
|
|
assert isinstance(etu["nom"], str)
|
|
|
|
assert isinstance(etu["prenom"], str)
|
|
|
|
assert isinstance(etu["nom_usuel"], str)
|
|
|
|
assert isinstance(etu["civilite"], str)
|
|
|
|
assert etu["date_naissance"] is None or isinstance(etu["date_naissance"], str)
|
|
|
|
assert etu["lieu_naissance"] is None or isinstance(etu["lieu_naissance"], str)
|
|
|
|
assert etu["dept_naissance"] is None or isinstance(etu["dept_naissance"], str)
|
|
|
|
assert etu["nationalite"] is None or isinstance(etu["nationalite"], str)
|
|
|
|
assert etu["statut"] is None or isinstance(etu["statut"], str)
|
|
|
|
assert etu["boursier"] is None or isinstance(etu["boursier"], bool)
|
|
|
|
assert etu["photo_filename"] is None or isinstance(etu["photo_filename"], str)
|
|
|
|
assert isinstance(etu["code_nip"], str)
|
|
|
|
assert isinstance(etu["code_ine"], str)
|
|
|
|
assert etu["scodoc7_id"] is None or isinstance(etu["scodoc7_id"], int)
|
|
|
|
assert isinstance(etu["email"], str)
|
|
|
|
assert etu["emailperso"] is None or isinstance(etu["emailperso"], str)
|
|
|
|
assert etu["domicile"] is None or isinstance(etu["domicile"], str)
|
|
|
|
assert etu["codepostaldomicile"] is None or isinstance(
|
|
|
|
etu["codepostaldomicile"], str
|
|
|
|
)
|
|
|
|
assert etu["villedomicile"] is None or isinstance(etu["villedomicile"], str)
|
|
|
|
assert etu["paysdomicile"] is None or isinstance(etu["paysdomicile"], str)
|
|
|
|
assert etu["telephone"] is None or isinstance(etu["telephone"], str)
|
|
|
|
assert etu["telephonemobile"] is None or isinstance(etu["telephonemobile"], str)
|
|
|
|
assert etu["fax"] is None or isinstance(etu["fax"], str)
|
|
|
|
assert isinstance(etu["typeadresse"], str)
|
|
|
|
assert etu["description"] is None or isinstance(etu["description"], int)
|
|
|
|
assert isinstance(etu["group_id"], int)
|
|
|
|
assert isinstance(etu["etat"], str)
|
|
|
|
assert isinstance(etu["civilite_str"], str)
|
|
|
|
assert isinstance(etu["nom_disp"], str)
|
|
|
|
assert isinstance(etu["nomprenom"], str)
|
|
|
|
assert isinstance(etu["ne"], str)
|
|
|
|
assert isinstance(etu["email_default"], str)
|
|
|
|
|
|
|
|
etat = "I"
|
|
|
|
r_etat = requests.get(
|
|
|
|
f"{API_URL}/partition/group/{group_id}/etat/{etat}",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r_etat.status_code == 200
|
|
|
|
|
|
|
|
assert isinstance(r_etat.json(), list)
|
|
|
|
|
|
|
|
for etu in r_etat.json():
|
|
|
|
assert verify_fields(etu, PARTITIONS_GROUPS_ETU_FIELDS)
|
|
|
|
assert isinstance(etu["etudid"], int)
|
|
|
|
assert isinstance(etu["id"], int)
|
|
|
|
assert isinstance(etu["dept_id"], int)
|
|
|
|
assert isinstance(etu["nom"], str)
|
|
|
|
assert isinstance(etu["prenom"], str)
|
|
|
|
assert isinstance(etu["nom_usuel"], str)
|
|
|
|
assert isinstance(etu["civilite"], str)
|
|
|
|
assert etu["date_naissance"] is None or isinstance(etu["date_naissance"], str)
|
|
|
|
assert etu["lieu_naissance"] is None or isinstance(etu["lieu_naissance"], str)
|
|
|
|
assert etu["dept_naissance"] is None or isinstance(etu["dept_naissance"], str)
|
|
|
|
assert etu["nationalite"] is None or isinstance(etu["nationalite"], str)
|
|
|
|
assert etu["statut"] is None or isinstance(etu["statut"], str)
|
|
|
|
assert etu["boursier"] is None or isinstance(etu["boursier"], bool)
|
|
|
|
assert etu["photo_filename"] is None or isinstance(etu["photo_filename"], str)
|
|
|
|
assert isinstance(etu["code_nip"], str)
|
|
|
|
assert isinstance(etu["code_ine"], str)
|
|
|
|
assert etu["scodoc7_id"] is None or isinstance(etu["scodoc7_id"], int)
|
|
|
|
assert isinstance(etu["email"], str)
|
|
|
|
assert etu["emailperso"] is None or isinstance(etu["emailperso"], str)
|
|
|
|
assert etu["domicile"] is None or isinstance(etu["domicile"], str)
|
|
|
|
assert etu["codepostaldomicile"] is None or isinstance(
|
|
|
|
etu["codepostaldomicile"], str
|
|
|
|
)
|
|
|
|
assert etu["villedomicile"] is None or isinstance(etu["villedomicile"], str)
|
|
|
|
assert etu["paysdomicile"] is None or isinstance(etu["paysdomicile"], str)
|
|
|
|
assert etu["telephone"] is None or isinstance(etu["telephone"], str)
|
|
|
|
assert etu["telephonemobile"] is None or isinstance(etu["telephonemobile"], str)
|
|
|
|
assert etu["fax"] is None or isinstance(etu["fax"], str)
|
|
|
|
assert isinstance(etu["typeadresse"], str)
|
|
|
|
assert etu["description"] is None or isinstance(etu["description"], int)
|
|
|
|
assert isinstance(etu["group_id"], int)
|
|
|
|
assert isinstance(etu["etat"], str)
|
|
|
|
assert isinstance(etu["civilite_str"], str)
|
|
|
|
assert isinstance(etu["nom_disp"], str)
|
|
|
|
assert isinstance(etu["nomprenom"], str)
|
|
|
|
assert isinstance(etu["ne"], str)
|
|
|
|
assert isinstance(etu["email_default"], str)
|
|
|
|
|
|
|
|
assert etat == etu["etat"]
|
2022-05-03 16:15:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
# # set_groups
|
2022-05-04 23:11:20 +02:00
|
|
|
# def test_set_groups(api_headers):
|
|
|
|
# """
|
2022-05-06 16:05:34 +02:00
|
|
|
# Test 'set_groups'
|
|
|
|
#
|
|
|
|
# Routes :
|
|
|
|
# - /partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>/delete/<string:groups_to_delete>"
|
|
|
|
# "/create/<string:groups_to_create>
|
2022-05-04 23:11:20 +02:00
|
|
|
# """
|
2022-05-03 16:15:04 +02:00
|
|
|
# r = requests.get(
|
|
|
|
# SCODOC_URL
|
|
|
|
# + "/partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>"
|
|
|
|
# "/delete/<string:groups_to_delete>/create/<string:groups_to_create>",
|
2022-05-04 23:11:20 +02:00
|
|
|
# headers=api_headers,
|
2022-05-03 16:15:04 +02:00
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|