forked from ScoDoc/ScoDoc
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
"""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
|
||
from app.but.import_refcomp import orebut_import_refcomp
|
||
from app.models.but_refcomp import (
|
||
ApcReferentielCompetences,
|
||
ApcCompetence,
|
||
ApcSituationPro,
|
||
)
|
||
|
||
ref_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||
<referentiel_competence specialite="RT" specialite_long="Réseaux et télécommunications" type="B.U.T.">
|
||
<competences>
|
||
<competence name="Administrer" numero="1" libelle_long="Administrer les réseaux et l’Internet"
|
||
couleur="c1">
|
||
<situations>
|
||
<situation>Conception et administration de l’infrastructure du réseau informatique d’une entreprise</situation>
|
||
<situation>Installation et administration des services réseau informatique d’une entreprise</situation>
|
||
</situations>
|
||
</competence>
|
||
<competence name="Tester" numero="2" libelle_long="Tester...">
|
||
<situations>
|
||
<situation>
|
||
Tests unitaires d'une application.
|
||
</situation>
|
||
</situations>
|
||
</competence>
|
||
</competences>
|
||
<parcours>
|
||
<parcour>
|
||
</parcour>
|
||
</parcours>
|
||
</referentiel_competence>
|
||
"""
|
||
|
||
|
||
def test_but_refcomp(test_client):
|
||
"""modèles ref. comp."""
|
||
f = io.StringIO(ref_xml)
|
||
ref = orebut_import_refcomp(f)
|
||
assert ref.references.count() == 2
|
||
assert ref.competences[0].situations.count() == 2
|
||
assert ref.competences[0].situations[0].libelle.startswith("Conception ")
|
||
# test cascades on delete
|
||
db.session.delete(ref)
|
||
db.session.commit()
|
||
assert ApcCompetence.query.count() == 0
|
||
assert ApcSituationPro.query.count() == 0
|