ScoDoc/tests/unit/test_formsemestre.py

37 lines
1.3 KiB
Python
Raw Normal View History

# -*- mode: python -*-
# -*- coding: utf-8 -*-
""" Test création/accès/clonage formsemestre
"""
import pytest
from tests.unit import yaml_setup
import app
from app.models import Formation
from app.scodoc import sco_formsemestre_edit
from config import TestConfig
DEPT = TestConfig.DEPT_TEST
def test_formsemestres_associate_new_version(test_client):
"""Test association à une nouvelle version du programme"""
app.set_sco_dept(DEPT)
# Construit la base de test GB une seule fois
# puis lance les tests de jury
yaml_setup.setup_from_yaml("tests/ressources/yaml/simple_formsemestres.yaml")
formation = Formation.query.filter_by(acronyme="BUT GEII", version=1).first()
formsemestres = formation.formsemestres.all()
# On a deux S1:
assert len(formsemestres) == 2
assert {s.semestre_id for s in formsemestres} == {1}
# Les rattache à une nouvelle version de la formation:
formsemestre_ids = [s.id for s in formsemestres]
sco_formsemestre_edit.do_formsemestres_associate_new_version(formsemestre_ids)
new_formation: Formation = Formation.query.filter_by(
acronyme="BUT GEII", version=2
).first()
assert new_formation
assert formsemestres[0].formation_id == new_formation.id
assert formsemestres[1].formation_id == new_formation.id