117 lines
2.8 KiB
Python
117 lines
2.8 KiB
Python
# -*- 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_absences.py
|
|
"""
|
|
|
|
import requests
|
|
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
|
from tests.api.tools_test_api import verify_fields
|
|
|
|
|
|
# absences
|
|
def test_absences():
|
|
|
|
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
|
|
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/1",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/nip/1",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/ine/1",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
|
|
# absences_justify
|
|
def test_absences_justify():
|
|
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/nip/1/just",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
r = requests.get(
|
|
SCODOC_URL + "/ScoDoc/api/absences/ine/1/just",
|
|
headers=HEADERS,
|
|
verify=CHECK_CERTIFICATE,
|
|
)
|
|
|
|
abs = r.json()[0]
|
|
|
|
fields_OK = verify_fields(abs, fields)
|
|
assert r.status_code == 200
|
|
assert fields_OK is True
|
|
|
|
|
|
# abs_groupe_etat
|
|
# def test_abs_groupe_etat():
|
|
# r = requests.get(
|
|
# SCODOC_URL
|
|
# + "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
|
|
# headers=HEADERS,
|
|
# verify=CHECK_CERTIFICATE,
|
|
# )
|
|
# assert r.status_code == 200
|