# -*- 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


# absences
def test_absences():
    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/etudid/<int:etudid>",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200

    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/nip/<int:nip>",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200

    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/ine/<int:ine>",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200


# absences_justify
def test_absences_justify():
    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200

    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/nip/1/just",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200

    r = requests.get(
        SCODOC_URL + "/ScoDoc/api/absences/ine/1/just",
        headers=HEADERS,
        verify=CHECK_CERTIFICATE,
    )
    assert r.status_code == 200


# 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
