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