diff --git a/app/entreprises/app_relations_entreprises.py b/app/entreprises/app_relations_entreprises.py
index b0eef62f..e8cce1e1 100644
--- a/app/entreprises/app_relations_entreprises.py
+++ b/app/entreprises/app_relations_entreprises.py
@@ -44,8 +44,8 @@ from app.entreprises.models import (
EntrepriseHistorique,
)
from app import email, db
-from app.scodoc import sco_preferences
from app.scodoc import sco_excel
+from app.scodoc import sco_utils as scu
from app.models import Departement
from app.scodoc.sco_permissions import Permission
@@ -392,7 +392,8 @@ def check_entreprise_import(entreprise_data):
else:
try:
req = requests.get(
- f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}"
+ f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}",
+ timeout=scu.SCO_EXT_TIMEOUT,
)
if req.status_code != 200:
return False
diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py
index fa43c148..c50cdd3b 100644
--- a/app/entreprises/forms.py
+++ b/app/entreprises/forms.py
@@ -24,9 +24,9 @@
#
##############################################################################
+from datetime import datetime
import re
import requests
-from datetime import datetime
from flask import url_for
from flask_wtf import FlaskForm
@@ -34,18 +34,17 @@ from flask_wtf.file import FileField, FileAllowed, FileRequired
from markupsafe import Markup
from sqlalchemy import text
from wtforms import (
- StringField,
- IntegerField,
- SubmitField,
- TextAreaField,
- SelectField,
- HiddenField,
- SelectMultipleField,
- DateField,
BooleanField,
+ DateField,
FieldList,
FormField,
- BooleanField,
+ HiddenField,
+ IntegerField,
+ SelectField,
+ SelectMultipleField,
+ StringField,
+ SubmitField,
+ TextAreaField,
)
from wtforms.validators import (
ValidationError,
@@ -64,9 +63,10 @@ from app.entreprises.models import (
EntrepriseTaxeApprentissage,
)
from app import db
-from app.models import Identite, Departement
from app.auth.models import User
from app.entreprises import SIRET_PROVISOIRE_START
+from app.models import Identite, Departement
+from app.scodoc import sco_utils as scu
CHAMP_REQUIS = "Ce champ est requis"
SUBMIT_MARGE = {"style": "margin-bottom: 10px;"}
@@ -139,7 +139,8 @@ class EntrepriseCreationForm(FlaskForm):
else:
try:
req = requests.get(
- f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}"
+ f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}",
+ timeout=scu.SCO_EXT_TIMEOUT,
)
if req.status_code != 200:
self.siret.errors.append("SIRET inexistant")
@@ -220,7 +221,8 @@ class EntrepriseModificationForm(FlaskForm):
else:
try:
req = requests.get(
- f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}"
+ f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}",
+ timeout=scu.SCO_EXT_TIMEOUT,
)
if req.status_code != 200:
raise ValidationError("SIRET inexistant")
diff --git a/app/models/ues.py b/app/models/ues.py
index ef2aecf2..1cafcf5b 100644
--- a/app/models/ues.py
+++ b/app/models/ues.py
@@ -339,6 +339,7 @@ class DispenseUE(db.Model):
la dispense étant une exception.
"""
+ __tablename__ = "dispenseUE"
__table_args__ = (db.UniqueConstraint("formsemestre_id", "ue_id", "etudid"),)
id = db.Column(db.Integer, primary_key=True)
formsemestre_id = formsemestre_id = db.Column(
diff --git a/app/pe/pe_semestretag.py b/app/pe/pe_semestretag.py
index 037fdad7..ee953593 100644
--- a/app/pe/pe_semestretag.py
+++ b/app/pe/pe_semestretag.py
@@ -299,8 +299,9 @@ class SemestreTag(pe_tagtable.TableTag):
modimpl_id, etudid
) # lecture de la note
coeff = modimpl.module.coefficient # le coeff
+ # nota: self.somme_coeffs peut être None
coeff_norm = (
- coeff / self.somme_coeffs if self.somme_coeffs != 0 else 0
+ coeff / self.somme_coeffs if self.somme_coeffs else 0
) # le coeff normalisé
else:
semtag_prec = SemestreTag(nt_prec, nt_prec.sem)
@@ -329,7 +330,7 @@ class SemestreTag(pe_tagtable.TableTag):
notes = []
coeffs_norm = []
ponderations = []
- for (moduleimpl_id, modimpl) in self.tagdict[
+ for moduleimpl_id, modimpl in self.tagdict[
tag
].items(): # pour chaque module du semestre relatif au tag
(note, coeff_norm) = self.get_noteEtCoeff_modimpl(moduleimpl_id, etudid)
@@ -345,7 +346,8 @@ class SemestreTag(pe_tagtable.TableTag):
def str_detail_resultat_d_un_tag(self, tag, etudid=None, delim=";"):
"""Renvoie une chaine de caractère décrivant les résultats d'étudiants à un tag :
rappelle les notes obtenues dans les modules à prendre en compte, les moyennes et les rangs calculés.
- Si etudid=None, tous les étudiants inscrits dans le semestre sont pris en compte. Sinon seuls les étudiants indiqués sont affichés."""
+ Si etudid=None, tous les étudiants inscrits dans le semestre sont pris en compte. Sinon seuls les étudiants indiqués sont affichés.
+ """
# Entete
chaine = delim.join(["%15s" % "nom", "etudid"]) + delim
taglist = self.get_all_tags()
@@ -440,7 +442,7 @@ class SemestreTag(pe_tagtable.TableTag):
taglist = self.get_all_tags()
for tag in taglist:
chaine += " > " + tag + ": "
- for (modid, mod) in self.tagdict[tag].items():
+ for modid, mod in self.tagdict[tag].items():
chaine += (
mod["module_code"]
+ " ("
@@ -459,6 +461,7 @@ class SemestreTag(pe_tagtable.TableTag):
# Fonctions diverses
# ************************************************************************
+
# *********************************************
def comp_coeff_pond(coeffs, ponderations):
"""
diff --git a/app/scodoc/sco_dump_db.py b/app/scodoc/sco_dump_db.py
index ad038ffe..851509f1 100644
--- a/app/scodoc/sco_dump_db.py
+++ b/app/scodoc/sco_dump_db.py
@@ -181,6 +181,7 @@ def _send_db(
"dept_name": getattr(g, "scodoc_dept", "-"),
"message": message or "",
"request_url": request_url or request.url,
+ "request_method": request.method,
"serial": _get_scodoc_serial(),
"sco_user": str(current_user),
"sent_by": f'"{current_user.get_nomcomplet()}" <{current_user.email}>',
@@ -188,8 +189,9 @@ def _send_db(
"sco_fullversion": scu.get_scodoc_version(),
"traceback_str": traceback_str,
},
+ timeout=scu.SCO_ORG_TIMEOUT,
)
- except requests.exceptions.ConnectionError as exc:
+ except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as exc:
log("ConnectionError: Impossible de joindre le serveur d'assistance")
raise ScoValueError(
"""
diff --git a/app/scodoc/sco_up_to_date.py b/app/scodoc/sco_up_to_date.py
index f819d76d..464a5ba0 100644
--- a/app/scodoc/sco_up_to_date.py
+++ b/app/scodoc/sco_up_to_date.py
@@ -47,8 +47,10 @@ def is_up_to_date() -> str:
return "
Mode développement
"
diag = ""
try:
- response = requests.get(scu.SCO_UP2DATE + "/" + SCOVERSION)
- except requests.exceptions.ConnectionError:
+ response = requests.get(
+ scu.SCO_UP2DATE + "/" + SCOVERSION, timeout=scu.SCO_ORG_TIMEOUT
+ )
+ except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
current_app.logger.debug("is_up_to_date: %s", diag)
return f"""Attention: installation de {SCONAME} non fonctionnelle.
Détails: pas de connexion à {scu.SCO_WEBSITE}.
diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py
index 06cac36d..639225e4 100644
--- a/app/scodoc/sco_utils.py
+++ b/app/scodoc/sco_utils.py
@@ -365,6 +365,9 @@ SCO_DEV_MAIL = "emmanuel.viennet@gmail.com" # SVP ne pas changer
# ne pas changer (ou vous perdez le support)
SCO_DUMP_UP_URL = "https://scodoc.org/scodoc-installmgr/upload-dump"
SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/check_version"
+SCO_ORG_TIMEOUT = 180 # contacts scodoc.org
+SCO_EXT_TIMEOUT = 180 # appels à des ressources extérieures (siret, ...)
+SCO_TEST_API_TIMEOUT = 5 # pour tests unitaires API
CSV_FIELDSEP = ";"
CSV_LINESEP = "\n"
CSV_MIMETYPE = "text/comma-separated-values"
diff --git a/tests/api/exemple-api-scodoc7.py b/tests/api/exemple-api-scodoc7.py
index 5dcbdf05..02e4cfb0 100644
--- a/tests/api/exemple-api-scodoc7.py
+++ b/tests/api/exemple-api-scodoc7.py
@@ -59,7 +59,9 @@ def GET(path: str, params=None, errmsg=None):
# ajoute auth
params["__ac_name"] = SCODOC_USER
params["__ac_password"] = SCODOC_PASSWORD
- r = requests.get(DEPT_URL + "/" + path, params=params, verify=CHECK_CERTIFICATE)
+ r = requests.get(
+ DEPT_URL + "/" + path, params=params, verify=CHECK_CERTIFICATE, timeout=10
+ )
if r.status_code != 200:
raise ScoError(errmsg or "erreur !")
return r.json() # decode la reponse JSON
@@ -69,7 +71,9 @@ def POST(path: str, data: dict, errmsg=None):
"""Post"""
data["__ac_name"] = data.get("__ac_name", SCODOC_USER)
data["__ac_password"] = data.get("__ac_password", SCODOC_PASSWORD)
- r = requests.post(DEPT_URL + "/" + path, data=data, verify=CHECK_CERTIFICATE)
+ r = requests.post(
+ DEPT_URL + "/" + path, data=data, verify=CHECK_CERTIFICATE, timeout=10
+ )
return r
diff --git a/tests/api/setup_test_api.py b/tests/api/setup_test_api.py
index 89433c2b..0a9d2402 100644
--- a/tests/api/setup_test_api.py
+++ b/tests/api/setup_test_api.py
@@ -17,6 +17,7 @@ import os
import requests
from dotenv import load_dotenv
import pytest
+from app.scodoc import sco_utils as scu
# --- Lecture configuration (variables d'env ou .env)
try:
@@ -45,7 +46,7 @@ class APIError(Exception):
def get_auth_headers(user, password) -> dict:
"Demande de jeton, dict à utiliser dans les en-têtes de requêtes http"
- ans = requests.post(API_URL + "/tokens", auth=(user, password))
+ ans = requests.post(API_URL + "/tokens", auth=(user, password), timeout=5)
if ans.status_code != 200:
raise APIError(f"Echec demande jeton par {user}")
token = ans.json()["token"]
@@ -73,7 +74,12 @@ def GET(path: str, headers: dict = None, errmsg=None, dept=None):
url = SCODOC_URL + f"/ScoDoc/{dept}/api" + path
else:
url = API_URL + path
- reply = requests.get(url, headers=headers or {}, verify=CHECK_CERTIFICATE)
+ reply = requests.get(
+ url,
+ headers=headers or {},
+ verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
+ )
if reply.status_code != 200:
raise APIError(
errmsg or f"""erreur status={reply.status_code} !""", reply.json()
@@ -105,6 +111,7 @@ def POST_JSON(path: str, data: dict = {}, headers: dict = None, errmsg=None, dep
json=data,
headers=headers or {},
verify=CHECK_CERTIFICATE,
+ timeout=10,
)
if r.status_code != 200:
raise APIError(errmsg or f"erreur status={r.status_code} !", r.json())
diff --git a/tests/api/test_api_absences.py b/tests/api/test_api_absences.py
index d64a7002..41107aa1 100644
--- a/tests/api/test_api_absences.py
+++ b/tests/api/test_api_absences.py
@@ -18,6 +18,7 @@ Utilisation :
"""
import requests
+from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
# Etudiant pour les tests
@@ -42,6 +43,7 @@ def test_absences(api_headers):
f"{API_URL}/absences/etudid/{ETUDID}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
absences = r.json()
@@ -72,6 +74,7 @@ def test_absences_justify(api_headers):
f"{API_URL}/absences/etudid/{ETUDID}/just",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
absences = r.json()
@@ -103,6 +106,7 @@ def test_abs_groupe_etat(api_headers):
f"{API_URL}/absences/abs_group_etat/{group_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
@@ -139,6 +143,7 @@ def test_abs_groupe_etat(api_headers):
f"{API_URL}/absences/abs_group_etat/group_id/{group_id}/date_debut/{date_debut}/date_fin/{date_fin}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r1.status_code == 200
@@ -187,6 +192,7 @@ def test_abs_groupe_etat(api_headers):
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+# timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -194,6 +200,7 @@ def test_abs_groupe_etat(api_headers):
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_not_just",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+# timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -202,5 +209,6 @@ def test_abs_groupe_etat(api_headers):
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_just",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+# timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
diff --git a/tests/api/test_api_departements.py b/tests/api/test_api_departements.py
index 8571d6ac..7553f739 100644
--- a/tests/api/test_api_departements.py
+++ b/tests/api/test_api_departements.py
@@ -33,6 +33,7 @@ from tests.api.tools_test_api import (
FORMSEMESTRE_FIELDS,
verify_occurences_ids_etuds,
)
+from app.scodoc import sco_utils as scu
def test_create_dept(api_admin_headers):
@@ -72,6 +73,7 @@ def test_departements(api_headers):
API_URL + "/departements_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
departements_ids = r.json()
@@ -94,6 +96,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/id/{dept_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
dept_a = r.json()
@@ -102,6 +105,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{dept_a['acronym']}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
dept_b = r.json()
@@ -119,6 +123,7 @@ def test_departements(api_headers):
API_URL + "/departements",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
@@ -127,6 +132,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{dept_a['acronym']}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
dept_ids_a = r.json()
@@ -135,6 +141,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/id/{dept_a['id']}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
dept_ids_b = r.json()
@@ -151,6 +158,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{id_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -158,6 +166,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{id_inexistant}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -166,6 +175,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{acronym_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -173,6 +183,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{acronym_inexistant}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -184,6 +195,7 @@ def test_list_etudiants(api_headers):
API_URL + "/departement/TAPI/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud_a = r.json()[0]
@@ -192,6 +204,7 @@ def test_list_etudiants(api_headers):
API_URL + "/departement/id/1/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud_b = r.json()[0]
@@ -216,6 +229,7 @@ def test_list_etudiants(api_headers):
f"{API_URL}/departement/{id_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -224,6 +238,7 @@ def test_list_etudiants(api_headers):
f"{API_URL}/departement/{acronym_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -235,6 +250,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/id/{dept_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
dept = r.json()
@@ -245,6 +261,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/{dept['acronym']}/formsemestres_courants?date_courante=2022-07-01",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
result_a = r.json()
@@ -254,6 +271,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/id/{dept['id']}/formsemestres_courants?date_courante=2022-07-01",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
result_b = r.json()
diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py
index b4fc97f3..203c587a 100644
--- a/tests/api/test_api_etudiants.py
+++ b/tests/api/test_api_etudiants.py
@@ -18,6 +18,7 @@ Utilisation :
"""
import requests
+from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
@@ -69,6 +70,7 @@ def test_etudiants_courant(api_headers):
API_URL + "/etudiants/courants?date_courante=2022-07-01",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etudiants = r.json()
@@ -90,6 +92,7 @@ def test_etudiants_courant(api_headers):
API_URL + "/etudiants/courants/long?date_courante=2022-07-01",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etudiants = r.json()
@@ -109,6 +112,7 @@ def test_etudiant(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID),
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud = r.json()
@@ -123,6 +127,7 @@ def test_etudiant(api_headers):
API_URL + "/etudiant/nip/" + code_nip,
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud_nip = r.json()
@@ -153,6 +158,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/etudid/" + str(ETUDID),
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud = r.json()
@@ -170,6 +176,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/nip/" + code_nip,
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud_nip = r.json()
@@ -191,6 +198,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/ine/" + code_ine,
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
etud_ine = r.json()
@@ -211,6 +219,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/etudid/",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -226,6 +235,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
list_formsemestres = r.json()
@@ -272,6 +282,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
formsemestres = r.json()
@@ -285,6 +296,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
formsemestres = r.json()
@@ -306,6 +318,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bulletin = r.json()
@@ -500,7 +513,7 @@ def test_etudiant_bulletin_semestre(api_headers):
assert verify_fields(bulletin_ues, BULLETIN_UES_FIELDS) is True
assert isinstance(bulletin_ues, dict)
- for (key_ue, value_ue) in bulletin_ues.items():
+ for key_ue, value_ue in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str)
@@ -636,6 +649,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bul = r.json()
@@ -646,6 +660,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bul = r.json()
@@ -659,6 +674,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -668,6 +684,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -676,6 +693,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
@@ -686,6 +704,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bul = r.json()
@@ -697,6 +716,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bul = r.json()
@@ -707,6 +727,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
bul = r.json()
@@ -719,6 +740,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -728,6 +750,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
#
@@ -736,6 +759,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
+ # timeout=scu.SCO_TEST_API_TIMEOUT,
# )
# assert r.status_code == 200
@@ -744,6 +768,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/189919919119191/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -771,6 +796,7 @@ def test_etudiant_groups(api_headers):
API_URL + "/etudiant/etudid/1/formsemestre/1/groups",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
groups = r.json()
diff --git a/tests/api/test_api_evaluations.py b/tests/api/test_api_evaluations.py
index 383f5fe5..4a306474 100644
--- a/tests/api/test_api_evaluations.py
+++ b/tests/api/test_api_evaluations.py
@@ -19,6 +19,7 @@ Utilisation :
import requests
+from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
verify_fields,
@@ -39,6 +40,7 @@ def test_evaluations(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl_id}/evaluations",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
list_eval = r.json()
@@ -75,6 +77,7 @@ def test_evaluation_notes(
f"{API_URL}/evaluation/{eval_id}/notes",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
eval_notes = r.json()
diff --git a/tests/api/test_api_formations.py b/tests/api/test_api_formations.py
index d4202f92..ebe34d34 100644
--- a/tests/api/test_api_formations.py
+++ b/tests/api/test_api_formations.py
@@ -19,6 +19,7 @@ Utilisation :
import requests
+from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
verify_fields,
@@ -41,6 +42,7 @@ def test_formations_ids(api_headers):
API_URL + "/formations_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
formations_ids = r.json()
@@ -59,6 +61,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{id_formation}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
formation = r.json()
@@ -86,6 +89,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{formation['formation_id']}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r1.status_code == 200
formation1 = r1.json()
@@ -98,6 +102,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error.status_code == 404
@@ -110,6 +115,7 @@ def test_formation_export(api_headers):
API_URL + "/formation/1/export",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
export_formation = r.json()
@@ -185,6 +191,7 @@ def test_formation_export(api_headers):
f"{API_URL}/formation/export/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error.status_code == 404
@@ -197,6 +204,7 @@ def test_formation_export_with_ids(api_headers):
API_URL + "/formation/1/export_with_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
export_formation = r.json()
@@ -215,6 +223,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
moduleimpl = r.json()
@@ -257,6 +266,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl['moduleimpl_id']}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r1.status_code == 200
moduleimpl1 = r1.json()
@@ -269,6 +279,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/formation/moduleimpl/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error.status_code == 404
@@ -281,6 +292,7 @@ def test_referentiel_competences(api_headers):
f"{API_URL}/formation/1/referentiel_competences",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
@@ -305,5 +317,6 @@ def test_referentiel_competences(api_headers):
f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error.status_code == 404
diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py
index 6b96e2ce..10ed4090 100644
--- a/tests/api/test_api_formsemestre.py
+++ b/tests/api/test_api_formsemestre.py
@@ -19,6 +19,8 @@ Utilisation :
import json
import requests
+from app.scodoc import sco_utils as scu
+
from tests.api.setup_test_api import (
API_URL,
CHECK_CERTIFICATE,
@@ -72,6 +74,7 @@ def test_formsemestre(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
formsemestre = r.json()
@@ -115,6 +118,7 @@ def test_formsemestre(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -128,6 +132,7 @@ def test_formsemestre_apo(api_headers):
f"{API_URL}/formsemestres/query?etape_apo={etape_apo}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
list_formsemestre = r.json()
@@ -188,6 +193,7 @@ def test_bulletins(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}/bulletins",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
@@ -384,7 +390,7 @@ def test_bulletins(api_headers):
bulletin_ues = bul["ues"]
assert isinstance(bulletin_ues, dict)
- for (key_ue, value_ue) in bulletin_ues.items():
+ for key_ue, value_ue in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str)
@@ -550,6 +556,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error.status_code == 404
@@ -557,6 +564,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/demissionnaires",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error_demissionnaires.status_code == 404
@@ -564,6 +572,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r_error_defaillants.status_code == 404
@@ -577,6 +586,7 @@ def test_formsemestre_programme(api_headers):
API_URL + "/formsemestre/1/programme",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
prog = r.json()
@@ -678,6 +688,7 @@ def test_etat_evals(api_headers):
f"{API_URL}/formsemestre/{invalid_id}/etat_evals",
headers=headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 404
@@ -693,6 +704,7 @@ def test_formsemestre_resultat(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}/resultats",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
res = r.json()
diff --git a/tests/api/test_api_logos.py b/tests/api/test_api_logos.py
index 8277c184..b89855b6 100644
--- a/tests/api/test_api_logos.py
+++ b/tests/api/test_api_logos.py
@@ -14,6 +14,9 @@ utilisation:
# Ce test a une logique très différente des autres : A UNIFIER
import requests
+
+from app.scodoc import sco_utils as scu
+from scodoc import app
from tests.api.setup_test_api import (
API_URL,
api_admin_headers,
@@ -21,7 +24,6 @@ from tests.api.setup_test_api import (
CHECK_CERTIFICATE,
)
-from scodoc import app
from tests.unit.config_test_logos import (
create_super_token,
create_admin_token,
@@ -39,6 +41,7 @@ def test_super_access(api_admin_headers):
API_URL + "/logos",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.json() is not None
@@ -52,6 +55,7 @@ def test_lambda_access(api_headers):
API_URL + "/logos",
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 401
@@ -64,6 +68,7 @@ def test_global_logos(api_admin_headers):
API_URL + "/logos",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.json() is not None
@@ -81,6 +86,7 @@ def test_local_by_id_logos(api_admin_headers):
API_URL + "/departement/id/1/logos",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.json() is not None
@@ -111,6 +117,7 @@ def test_local_png_by_id_logo(api_admin_headers):
API_URL + "/departement/id/1/logo/D",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png"
@@ -126,6 +133,7 @@ def test_global_png_logo(api_admin_headers):
API_URL + "/logo/C",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png"
@@ -141,6 +149,7 @@ def test_global_jpg_logo(api_admin_headers):
API_URL + "/logo/B",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg"
@@ -156,6 +165,7 @@ def test_local_png_by_name_logo(api_admin_headers):
API_URL + "/departement/TAPI/logo/D",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png"
@@ -171,6 +181,7 @@ def test_local_jpg_by_id_logo(api_admin_headers):
API_URL + "/departement/id/1/logo/A",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg"
@@ -186,6 +197,7 @@ def test_local_jpg_by_name_logo(api_admin_headers):
API_URL + "/departement/TAPI/logo/A",
headers=api_admin_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg"
diff --git a/tests/api/test_api_permissions.py b/tests/api/test_api_permissions.py
index fc0c628f..fbaab34a 100644
--- a/tests/api/test_api_permissions.py
+++ b/tests/api/test_api_permissions.py
@@ -16,6 +16,7 @@ import requests
from tests.api.setup_test_api import API_URL, SCODOC_URL, CHECK_CERTIFICATE, api_headers
from app import create_app
+from app.scodoc import sco_utils as scu
from config import RunningConfig
@@ -69,6 +70,7 @@ def test_permissions(api_headers):
SCODOC_URL + path,
headers=api_headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 200
@@ -81,11 +83,12 @@ def test_permissions(api_headers):
r = requests.get(
SCODOC_URL + path,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 401
# Demande un jeton pour "other"
- r = requests.post(API_URL + "/tokens", auth=("other", "other"))
+ r = requests.post(API_URL + "/tokens", auth=("other", "other"), timeout=10)
assert r.status_code == 200
token = r.json()["token"]
headers = {"Authorization": f"Bearer {token}"}
@@ -99,5 +102,6 @@ def test_permissions(api_headers):
SCODOC_URL + path,
headers=headers,
verify=CHECK_CERTIFICATE,
+ timeout=scu.SCO_TEST_API_TIMEOUT,
)
assert r.status_code == 401
diff --git a/tools/check_network.py b/tools/check_network.py
index ceaafa5e..205ace3b 100644
--- a/tools/check_network.py
+++ b/tools/check_network.py
@@ -4,7 +4,9 @@ import requests
import sco_version
import app.scodoc.sco_utils as scu
-response = requests.get(scu.SCO_UP2DATE + "/" + sco_version.SCOVERSION)
+response = requests.get(
+ scu.SCO_UP2DATE + "/" + sco_version.SCOVERSION, timeout=scu.SCO_ORG_TIMEOUT
+)
print(response.status_code)
print(response.text)