ScoDoc/tests/unit/test_refcomp.py

39 lines
1.1 KiB
Python
Raw Normal View History

2021-12-02 12:08:03 +01:00
"""Test models referentiel compétences
Utiliser par exemple comme:
pytest tests/unit/test_refcomp.py
"""
import io
from flask import g
import app
from app import db
2021-12-03 14:13:49 +01:00
from app import models
2021-12-02 12:08:03 +01:00
from app.but.import_refcomp import orebut_import_refcomp
from app.models.but_refcomp import (
ApcReferentielCompetences,
ApcCompetence,
ApcSituationPro,
)
def test_but_refcomp(test_client):
"""modèles ref. comp."""
2022-01-15 21:36:06 +01:00
xml_data = open(
"ressources/referentiels/but2022/competences/but-RT-05012022-081735.xml"
).read()
2021-12-03 14:13:49 +01:00
dept_id = models.Departement.query.first().id
ref = orebut_import_refcomp(xml_data, dept_id)
assert ref.competences.count() == 13
assert ref.competences[0].situations.count() == 3
2021-12-02 12:08:03 +01:00
assert ref.competences[0].situations[0].libelle.startswith("Conception ")
2021-12-03 14:13:49 +01:00
assert (
ref.competences[-1].situations[-1].libelle
== "Administration des services multimédia"
)
2021-12-02 12:08:03 +01:00
# test cascades on delete
db.session.delete(ref)
db.session.commit()
assert ApcCompetence.query.count() == 0
assert ApcSituationPro.query.count() == 0