From 56d708569d826226fe5077c80219cc68aadbda24 Mon Sep 17 00:00:00 2001 From: IDK Date: Thu, 12 Aug 2021 13:54:56 +0200 Subject: [PATCH] default formsemestre modality --- app/models/formsemestre.py | 12 +++++++++--- tests/conftest.py | 1 + tests/unit/sco_fake_gen.py | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 7ce6f172c5..4b881ac22c 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -102,14 +102,20 @@ class NotesFormModalite(db.Model): __tablename__ = "notes_form_modalites" + DEFAULT_MODALITE = "FI" + id = db.Column(db.Integer, primary_key=True) - modalite = db.Column(db.String(16), unique=True, index=True) # code + modalite = db.Column( + db.String(16), + unique=True, + index=True, + default=DEFAULT_MODALITE, + server_default=DEFAULT_MODALITE, + ) # code titre = db.Column(db.Text()) # texte explicatif # numero = ordre de presentation) numero = db.Column(db.Integer) - DEFAULT_MODALITE = "FI" - @staticmethod def insert_modalites(): """Create default modalities""" diff --git a/tests/conftest.py b/tests/conftest.py index fe1e879964..8f3a853ea7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,6 +48,7 @@ def test_client(): yield client # ndb.close_dept_connection() # Teardown: + db.session.commit() db.session.remove() clear_scodoc_cache() # db.drop_all() diff --git a/tests/unit/sco_fake_gen.py b/tests/unit/sco_fake_gen.py index 86cbd2db4a..130bae44ef 100644 --- a/tests/unit/sco_fake_gen.py +++ b/tests/unit/sco_fake_gen.py @@ -18,6 +18,7 @@ import typing import scodoc_manager from config import Config from app.auth.models import User +from app.models import NotesFormModalite from app.scodoc import notesdb as ndb from app.scodoc import sco_codes_parcours from app.scodoc import sco_edit_formation @@ -228,7 +229,7 @@ class ScoFake(object): bul_hide_xml=None, gestion_semestrielle=None, bul_bgcolor=None, - modalite=None, + modalite=NotesFormModalite.DEFAULT_MODALITE, resp_can_edit=None, resp_can_change_ens=None, ens_can_edit_eval=None,