Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
2 changed files with 10 additions and 2 deletions
Showing only changes of commit 46dada71a6 - Show all commits

View File

@ -148,7 +148,7 @@ def handle_invalid_usage(error):
# JSON ENCODING
# used by some internal finctions
# the API is now using flask_son, NOT THIS ENCODER
# the API is now using flask_json, NOT THIS ENCODER
class ScoDocJSONEncoder(json.JSONEncoder):
def default(self, o): # pylint: disable=E0202
if isinstance(o, (datetime.date, datetime.datetime)):
@ -260,7 +260,13 @@ def create_app(config_class=DevConfig):
CAS(app, url_prefix="/cas", configuration_function=cas.set_cas_configuration)
app.wsgi_app = ReverseProxied(app.wsgi_app)
FlaskJSON(app)
app_json = FlaskJSON(app)
@app_json.encoder
def scodoc_json_encoder(o):
"Overide default date encoding (RFC 822) and use ISO"
if isinstance(o, (datetime.date, datetime.datetime)):
return o.isoformat()
# Pour conserver l'ordre des objets dans les JSON:
# e.g. l'ordre des UE dans les bulletins

View File

@ -17,6 +17,7 @@ Utilisation :
pytest tests/api/test_api_etudiants.py
"""
import re
import requests
from app.scodoc import sco_utils as scu
@ -100,6 +101,7 @@ def test_etudiants_courant(api_headers):
etud = etudiants[-1]
assert verify_fields(etud, ETUD_FIELDS) is True
assert re.match(r"^\d{4}-\d\d-\d\d$", etud["date_naissance"])
def test_etudiant(api_headers):