tests unitaires Modèle + MAJ fichier migration
This commit is contained in:
parent
6c88dfa722
commit
4df1bdda8e
@ -1,7 +1,7 @@
|
|||||||
"""Ajout Modeles Assiduites Justificatifs
|
"""Ajout Modeles Assiduites Justificatifs
|
||||||
|
|
||||||
Revision ID: 530594458193
|
Revision ID: 530594458193
|
||||||
Revises: f95656fdd3ef
|
Revises: 3c12f5850cff
|
||||||
Create Date: 2022-12-19 13:56:28.597632
|
Create Date: 2022-12-19 13:56:28.597632
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -10,45 +10,73 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '530594458193'
|
revision = "530594458193"
|
||||||
down_revision = 'f95656fdd3ef'
|
down_revision = "3c12f5850cff"
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.create_table('justificatifs',
|
op.create_table(
|
||||||
sa.Column('justifid', sa.Integer(), nullable=False),
|
"justificatifs",
|
||||||
sa.Column('date_debut', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
sa.Column("justifid", sa.Integer(), nullable=False),
|
||||||
sa.Column('date_fin', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
sa.Column(
|
||||||
sa.Column('etudid', sa.Integer(), nullable=False),
|
"date_debut",
|
||||||
sa.Column('etat', sa.Integer(), nullable=True),
|
sa.DateTime(timezone=True),
|
||||||
sa.Column('raison', sa.Text(), nullable=True),
|
server_default=sa.text("now()"),
|
||||||
sa.Column('fichier', sa.Integer(), nullable=True),
|
nullable=False,
|
||||||
sa.ForeignKeyConstraint(['etudid'], ['identite.id'], ondelete='CASCADE'),
|
),
|
||||||
sa.PrimaryKeyConstraint('justifid')
|
sa.Column(
|
||||||
|
"date_fin",
|
||||||
|
sa.DateTime(timezone=True),
|
||||||
|
server_default=sa.text("now()"),
|
||||||
|
nullable=False,
|
||||||
|
),
|
||||||
|
sa.Column("etudid", sa.Integer(), nullable=False),
|
||||||
|
sa.Column("etat", sa.Integer(), nullable=True),
|
||||||
|
sa.Column("raison", sa.Text(), nullable=True),
|
||||||
|
sa.Column("fichier", sa.Integer(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(["etudid"], ["identite.id"], ondelete="CASCADE"),
|
||||||
|
sa.PrimaryKeyConstraint("justifid"),
|
||||||
)
|
)
|
||||||
op.create_index(op.f('ix_justificatifs_etudid'), 'justificatifs', ['etudid'], unique=False)
|
op.create_index(
|
||||||
op.create_table('assiduites',
|
op.f("ix_justificatifs_etudid"), "justificatifs", ["etudid"], unique=False
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
)
|
||||||
sa.Column('date_debut', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
op.create_table(
|
||||||
sa.Column('date_fin', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
"assiduites",
|
||||||
sa.Column('moduleimpl_id', sa.Integer(), nullable=True),
|
sa.Column("id", sa.Integer(), nullable=False),
|
||||||
sa.Column('etudid', sa.Integer(), nullable=False),
|
sa.Column(
|
||||||
sa.Column('etat', sa.Integer(), nullable=False),
|
"date_debut",
|
||||||
sa.ForeignKeyConstraint(['etudid'], ['identite.id'], ondelete='CASCADE'),
|
sa.DateTime(timezone=True),
|
||||||
sa.ForeignKeyConstraint(['moduleimpl_id'], ['notes_moduleimpl.id'], ondelete='SET NULL'),
|
server_default=sa.text("now()"),
|
||||||
sa.PrimaryKeyConstraint('id')
|
nullable=False,
|
||||||
|
),
|
||||||
|
sa.Column(
|
||||||
|
"date_fin",
|
||||||
|
sa.DateTime(timezone=True),
|
||||||
|
server_default=sa.text("now()"),
|
||||||
|
nullable=False,
|
||||||
|
),
|
||||||
|
sa.Column("moduleimpl_id", sa.Integer(), nullable=True),
|
||||||
|
sa.Column("etudid", sa.Integer(), nullable=False),
|
||||||
|
sa.Column("etat", sa.Integer(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["etudid"], ["identite.id"], ondelete="CASCADE"),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
["moduleimpl_id"], ["notes_moduleimpl.id"], ondelete="SET NULL"
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
op.f("ix_assiduites_etudid"), "assiduites", ["etudid"], unique=False
|
||||||
)
|
)
|
||||||
op.create_index(op.f('ix_assiduites_etudid'), 'assiduites', ['etudid'], unique=False)
|
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_index(op.f('ix_assiduites_etudid'), table_name='assiduites')
|
op.drop_index(op.f("ix_assiduites_etudid"), table_name="assiduites")
|
||||||
op.drop_table('assiduites')
|
op.drop_table("assiduites")
|
||||||
op.drop_index(op.f('ix_justificatifs_etudid'), table_name='justificatifs')
|
op.drop_index(op.f("ix_justificatifs_etudid"), table_name="justificatifs")
|
||||||
op.drop_table('justificatifs')
|
op.drop_table("justificatifs")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
@ -10,6 +10,8 @@ Ecrit par HARTMANN Matthias (en s'inspirant de tests.unit.test_abs_count.py par
|
|||||||
|
|
||||||
from tests.unit import sco_fake_gen
|
from tests.unit import sco_fake_gen
|
||||||
|
|
||||||
|
from app import db
|
||||||
|
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
import app.scodoc.sco_assiduites as scass
|
import app.scodoc.sco_assiduites as scass
|
||||||
from app.models import Assiduite, Identite, FormSemestre
|
from app.models import Assiduite, Identite, FormSemestre
|
||||||
@ -102,6 +104,44 @@ def test_general(test_client):
|
|||||||
verifier_comptage_et_filtrage(
|
verifier_comptage_et_filtrage(
|
||||||
etuds, moduleimpls, (formsemestre_1, formsemestre_2, formsemestre_3)
|
etuds, moduleimpls, (formsemestre_1, formsemestre_2, formsemestre_3)
|
||||||
)
|
)
|
||||||
|
editer_supprimer_assiduiter(etuds, moduleimpls)
|
||||||
|
|
||||||
|
|
||||||
|
def editer_supprimer_assiduiter(etuds: list[Identite], moduleimpls: list[int]):
|
||||||
|
"""
|
||||||
|
Troisième Partie:
|
||||||
|
- Vérification de l'édition des assiduitées
|
||||||
|
- Vérification de la suppression des assiduitées
|
||||||
|
"""
|
||||||
|
|
||||||
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
|
||||||
|
ass1: Assiduite = etuds[0].assiduites.first()
|
||||||
|
ass2: Assiduite = etuds[1].assiduites.first()
|
||||||
|
ass3: Assiduite = etuds[2].assiduites.first()
|
||||||
|
|
||||||
|
# Modification de l'état
|
||||||
|
ass1.etat = scu.EtatAssiduite.RETARD
|
||||||
|
db.session.add(ass1)
|
||||||
|
# Modification du moduleimpl
|
||||||
|
ass2.moduleimpl_id = moduleimpls[0]
|
||||||
|
db.session.add(ass2)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
# Vérification du changement
|
||||||
|
assert (
|
||||||
|
scass.filter_by_etat(etuds[0].assiduites, "retard").count() == 3
|
||||||
|
), "Edition d'assiduité mauvais"
|
||||||
|
assert (
|
||||||
|
scass.filter_by_module_impl(etuds[1].assiduites, moduleimpls[0]).count() == 2
|
||||||
|
), "Edition d'assiduité mauvais"
|
||||||
|
|
||||||
|
# Supression d'une assiduité
|
||||||
|
|
||||||
|
db.session.delete(ass3)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
assert etuds[2].assiduites.count() == 5, "Supression d'assiduité mauvais"
|
||||||
|
|
||||||
|
|
||||||
def ajouter_assiduites(etuds: list[Identite], moduleimpls: list[int]):
|
def ajouter_assiduites(etuds: list[Identite], moduleimpls: list[int]):
|
||||||
|
@ -123,7 +123,13 @@ def test_ue_moy(test_client):
|
|||||||
modimpl.module.ue.type != UE_SPORT for modimpl in formsemestre.modimpls_sorted
|
modimpl.module.ue.type != UE_SPORT for modimpl in formsemestre.modimpls_sorted
|
||||||
]
|
]
|
||||||
etud_moy_ue = moy_ue.compute_ue_moys_apc(
|
etud_moy_ue = moy_ue.compute_ue_moys_apc(
|
||||||
sem_cube, etuds, modimpls, modimpl_inscr_df, modimpl_coefs_df, modimpl_mask
|
sem_cube,
|
||||||
|
etuds,
|
||||||
|
modimpls,
|
||||||
|
modimpl_inscr_df,
|
||||||
|
modimpl_coefs_df,
|
||||||
|
modimpl_mask,
|
||||||
|
set(),
|
||||||
)
|
)
|
||||||
assert etud_moy_ue[ue1.id][etudid] == n1
|
assert etud_moy_ue[ue1.id][etudid] == n1
|
||||||
assert etud_moy_ue[ue2.id][etudid] == n1
|
assert etud_moy_ue[ue2.id][etudid] == n1
|
||||||
|
Loading…
Reference in New Issue
Block a user