forked from ScoDoc/DocScoDoc
Fixes #466
This commit is contained in:
parent
90811fdc0e
commit
9b0dec8675
@ -347,8 +347,8 @@ def etat_evals(formsemestre_id: int):
|
||||
result = []
|
||||
for modimpl_id in nt.modimpls_results:
|
||||
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id]
|
||||
modimpl = ModuleImpl.query.get_or_404(modimpl_id)
|
||||
modimpl_dict = modimpl.to_dict()
|
||||
modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id)
|
||||
modimpl_dict = modimpl.to_dict(convert_objects=True)
|
||||
|
||||
list_eval = []
|
||||
for evaluation_id in modimpl_results.evaluations_etat:
|
||||
@ -403,7 +403,6 @@ def etat_evals(formsemestre_id: int):
|
||||
|
||||
modimpl_dict["evaluations"] = list_eval
|
||||
result.append(modimpl_dict)
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
|
@ -86,6 +86,10 @@ class ModuleImpl(db.Model):
|
||||
"""
|
||||
d = dict(self.__dict__)
|
||||
d.pop("_sa_instance_state", None)
|
||||
if convert_objects:
|
||||
# on n'exporte pas le formsemestre et les inscriptions
|
||||
d.pop("formsemestre", None)
|
||||
d.pop("inscriptions", None)
|
||||
# ScoDoc7 output_formators: (backward compat)
|
||||
d["moduleimpl_id"] = self.id
|
||||
d["ens"] = [
|
||||
|
@ -75,6 +75,9 @@ class Module(db.Model):
|
||||
d.pop("_sa_instance_state", None)
|
||||
if convert_objects:
|
||||
d["parcours"] = [p.to_dict() for p in self.parcours]
|
||||
d["ue_coefs"] = [
|
||||
c.to_dict(convert_objects=convert_objects) for c in self.ue_coefs
|
||||
]
|
||||
if not with_matiere:
|
||||
d.pop("matiere", None)
|
||||
if not with_ue:
|
||||
@ -240,6 +243,8 @@ class ModuleUECoef(db.Model):
|
||||
"""
|
||||
d = dict(self.__dict__)
|
||||
d.pop("_sa_instance_state", None)
|
||||
if convert_objects:
|
||||
d["ue"] = self.ue.to_dict(with_module_ue_coefs=False, convert_objects=True)
|
||||
return d
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ class UniteEns(db.Model):
|
||||
self.semestre_idx} {
|
||||
'EXTERNE' if self.is_external else ''})>"""
|
||||
|
||||
def to_dict(self, convert_objects=False):
|
||||
def to_dict(self, convert_objects=False, with_module_ue_coefs=True):
|
||||
"""as a dict, with the same conversions as in ScoDoc7
|
||||
(except ECTS: keep None)
|
||||
If convert_objects, convert all attributes to native types
|
||||
@ -74,10 +74,13 @@ class UniteEns(db.Model):
|
||||
e["ects"] = e["ects"]
|
||||
e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0
|
||||
e["code_apogee"] = e["code_apogee"] or "" # pas de None
|
||||
if convert_objects:
|
||||
e["module_ue_coefs"] = [
|
||||
c.to_dict(convert_objects=True) for c in self.module_ue_coefs
|
||||
]
|
||||
if with_module_ue_coefs:
|
||||
if convert_objects:
|
||||
e["module_ue_coefs"] = [
|
||||
c.to_dict(convert_objects=True) for c in self.module_ue_coefs
|
||||
]
|
||||
else:
|
||||
e.pop("module_ue_coefs", None)
|
||||
return e
|
||||
|
||||
def is_locked(self):
|
||||
|
@ -20,6 +20,10 @@ Démarche générale:
|
||||
flask init-test-database
|
||||
```
|
||||
|
||||
en plus court: ```
|
||||
tools/create_database.sh --drop SCODOC_TEST_API && flask db upgrade &&flask sco-db-init --erase && flask init-test-database
|
||||
```
|
||||
|
||||
2. On lance le serveur ScoDoc sur cette base
|
||||
```
|
||||
flask run --host 0.0.0.0
|
||||
|
@ -19,7 +19,13 @@ Utilisation :
|
||||
|
||||
import requests
|
||||
|
||||
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
||||
from tests.api.setup_test_api import (
|
||||
API_URL,
|
||||
CHECK_CERTIFICATE,
|
||||
GET,
|
||||
POST_JSON,
|
||||
api_headers,
|
||||
)
|
||||
|
||||
from tests.api.tools_test_api import (
|
||||
verify_fields,
|
||||
@ -652,20 +658,13 @@ def test_formsemestre_programme(api_headers):
|
||||
assert verify_fields(sae, MODIMPL_FIELDS)
|
||||
|
||||
|
||||
def test_etat_evals(
|
||||
api_headers,
|
||||
):
|
||||
def test_etat_evals(api_headers):
|
||||
"""
|
||||
Route : /formsemestre/<int:formsemestre_id>/etat_evals
|
||||
"""
|
||||
r = requests.get(
|
||||
API_URL + "/formsemestre/1/etat_evals",
|
||||
headers=api_headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
|
||||
etat_evals = r.json()
|
||||
formsemestre_id = 1
|
||||
headers = api_headers
|
||||
etat_evals = GET(f"/formsemestre/{formsemestre_id}/etat_evals", headers=headers)
|
||||
|
||||
assert len(etat_evals) == 21
|
||||
|
||||
@ -728,10 +727,10 @@ def test_etat_evals(
|
||||
)
|
||||
|
||||
##### ERROR #####
|
||||
fake_eval_id = 153165161656849846516511321651651
|
||||
invalid_eval_id = 153165161656849846516511321651651
|
||||
r = requests.get(
|
||||
f"{API_URL}/formsemestre/{fake_eval_id}/etat_evals",
|
||||
headers=api_headers,
|
||||
f"{API_URL}/formsemestre/{invalid_eval_id}/etat_evals",
|
||||
headers=headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 404
|
||||
|
@ -17,8 +17,6 @@ Utilisation :
|
||||
pytest tests/api/test_api_partitions.py
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
from tests.api.setup_test_api import (
|
||||
API_URL,
|
||||
CHECK_CERTIFICATE,
|
||||
|
Loading…
Reference in New Issue
Block a user