forked from ScoDoc/ScoDoc
Fix unit tests
This commit is contained in:
parent
d1d89cc427
commit
46cdaf75b8
@ -116,7 +116,7 @@ class Module(models.ScoDocModel):
|
|||||||
def create_from_dict(cls, data: dict) -> "Module":
|
def create_from_dict(cls, data: dict) -> "Module":
|
||||||
"""Create from given dict, add parcours"""
|
"""Create from given dict, add parcours"""
|
||||||
mod = super().create_from_dict(data)
|
mod = super().create_from_dict(data)
|
||||||
for p in data["parcours"]:
|
for p in data.get("parcours", []) or []:
|
||||||
if isinstance(p, ApcParcours):
|
if isinstance(p, ApcParcours):
|
||||||
parcour: ApcParcours = p
|
parcour: ApcParcours = p
|
||||||
else:
|
else:
|
||||||
|
@ -59,6 +59,7 @@ cli.register(app)
|
|||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_sco_utils():
|
def inject_sco_utils():
|
||||||
"Make scu available in all Jinja templates"
|
"Make scu available in all Jinja templates"
|
||||||
|
# if modified, put the same in conftest.py#27
|
||||||
return dict(scu=scu)
|
return dict(scu=scu)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from flask import g
|
from flask import g
|
||||||
from flask_login import login_user, logout_user, current_user
|
from flask_login import login_user
|
||||||
|
|
||||||
from config import TestConfig
|
from config import TestConfig
|
||||||
import app
|
import app
|
||||||
from app import db, create_app
|
from app import db, create_app
|
||||||
from app import initialize_scodoc_database, clear_scodoc_cache
|
from app import initialize_scodoc_database, clear_scodoc_cache
|
||||||
from app import models
|
from app import models
|
||||||
from app.auth.models import User, Role, UserRole, Permission
|
from app.auth.models import User, Role
|
||||||
from app.auth.models import get_super_admin
|
from app.auth.models import get_super_admin
|
||||||
from app.scodoc import sco_bulletins_standard
|
|
||||||
from app.scodoc import notesdb as ndb
|
from app.scodoc import notesdb as ndb
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
|
|
||||||
RESOURCES_DIR = "/opt/scodoc/tests/ressources"
|
RESOURCES_DIR = "/opt/scodoc/tests/ressources"
|
||||||
|
|
||||||
@ -23,6 +23,12 @@ def test_client():
|
|||||||
# Run tests:
|
# Run tests:
|
||||||
with apptest.test_client() as client:
|
with apptest.test_client() as client:
|
||||||
with apptest.app_context():
|
with apptest.app_context():
|
||||||
|
|
||||||
|
@apptest.context_processor
|
||||||
|
def inject_sco_utils():
|
||||||
|
"Make scu available in all Jinja templates"
|
||||||
|
return dict(scu=scu)
|
||||||
|
|
||||||
with apptest.test_request_context():
|
with apptest.test_request_context():
|
||||||
# initialize scodoc "g":
|
# initialize scodoc "g":
|
||||||
g.stored_get_formsemestre = {}
|
g.stored_get_formsemestre = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user