Exemple #1
0
def test_abandon(request_context, injector, db):
    x = prepare_test(injector, db)
    demande = DemandeRH(gestionnaire=x.joe_gdl)

    wf = LabsterWorkflow(demande, x.joe_gdl)
    wf.start()

    assert wf.current_state() == EN_EDITION
    assert demande.active
    assert wf.possible_transitions() == [ABANDONNER]

    wf.execute_transition(ABANDONNER)
    assert wf.current_state() == ABANDONNEE
    assert not demande.active
    assert not demande.editable
    assert demande.current_owners() == set()
Exemple #2
0
def test_gestionnaire_peut_soumettre(mocker, request_context, injector, db):
    # si la structure permet aux gestionnaires de soumettre directement
    # le gestionnaire voit le bouton soumettre (arrive à soumettre).

    x = prepare_test(injector, db)

    demande = DemandeRH(porteur=x.jim_porteur, structure=x.labo)
    mocker.patch.object(demande, "is_valid", return_value=True)

    x.labo.permettre_soummission_directe = True

    wf = LabsterWorkflow(demande, x.joe_gdl)
    wf.start()
    wf.execute_transition(SOUMETTRE)
    assert wf.state == EN_VALIDATION
Exemple #3
0
def test_prendre_la_main_dri(mocker, request_context, injector, db):
    x = prepare_test(injector, db)

    demande = DemandeRH(porteur=x.jim_porteur,
                        contact_labco=x.jules_dri,
                        structure=x.labo)

    mocker.patch.object(demande, "is_valid", return_value=True)
    mocker.patch.object(demande, "assigne_contact_labco")

    wf = LabsterWorkflow(demande, x.jim_porteur)
    wf.start()
    wf.execute_transition(SOUMETTRE)

    wf.set_actor(x.jake_directeur)
    wf.execute_transition(VALIDER_DIR)
    assert wf.state == EN_VERIFICATION

    # Jules2 veut prendre la main
    wf.set_actor(x.jules2_dri)
    assert wf.possible_transitions() == [
        PRENDRE_LA_MAIN_DGRTT,
        # REJETER_DGRTT,
        # COMMENTER,
    ]
    assert demande.contact_labco == x.jules_dri

    wf.execute_transition(PRENDRE_LA_MAIN_DGRTT)
    assert wf.possible_transitions() == [
        ACCUSER_RECEPTION,
        CONFIRMER_RECEVABILITE_DGRTT,
        REQUERIR_MODIFICATION_DGRTT,
        REJETER_DGRTT,
        COMMENTER,
    ]
    assert demande.contact_labco == x.jules2_dri

    wf.set_actor(x.jules_dri)
    assert wf.possible_transitions() == [
        PRENDRE_LA_MAIN_DGRTT,
        # REJETER_DGRTT,
        # COMMENTER,
    ]
Exemple #4
0
def test_demande_modification_dri(mocker, request_context, injector, db):
    x = prepare_test(injector, db)

    demande = DemandeRH(gestionnaire=x.joe_gdl,
                        porteur=x.jim_porteur,
                        structure=x.labo)
    mocker.patch.object(demande, "is_valid", return_value=True)

    wf = LabsterWorkflow(demande, x.joe_gdl)
    wf.start()

    wf.set_actor(x.jim_porteur)
    wf.execute_transition(SOUMETTRE)

    wf.set_actor(x.jake_directeur)
    wf.execute_transition(VALIDER_DIR)

    demande.contact_labco = x.jules_dri

    wf.set_actor(x.jules_dri)
    wf.execute_transition(ACCUSER_RECEPTION)
    wf.execute_transition(REQUERIR_MODIFICATION_DGRTT)

    wf.set_actor(x.jim_porteur)
    wf.execute_transition(SOUMETTRE)

    wf.set_actor(x.jules_dri)
    wf.execute_transition(CONFIRMER_RECEVABILITE_DGRTT)
    wf.execute_transition(REQUERIR_MODIFICATION_DGRTT)

    wf.set_actor(x.jim_porteur)
    wf.execute_transition(SOUMETTRE)

    wf.set_actor(x.jules_dri)
    wf.execute_transition(CONFIRMER_FINALISATION_DGRTT)

    assert not demande.active
Exemple #5
0
def test_demande_modification(mocker, request_context, injector, db):
    x = prepare_test(injector, db)

    demande = DemandeRH(porteur=x.jim_porteur, structure=x.labo)
    mocker.patch.object(demande, "is_valid", return_value=True)

    wf = LabsterWorkflow(demande, x.joe_gdl)
    wf.start()

    wf.set_actor(x.jim_porteur)
    wf.execute_transition(SOUMETTRE)
    assert wf.current_state() == EN_VALIDATION

    wf.set_actor(x.jake_directeur)
    wf.execute_transition(REQUERIR_MODIFICATION_DIR)
    assert wf.current_state() == EN_EDITION

    wf.set_actor(x.jim_porteur)
    wf.execute_transition(SOUMETTRE)
    assert wf.current_state() == EN_VALIDATION
Exemple #6
0
def test_happy_path(mocker, injector, request_context, db, db_session):
    x = prepare_test(injector, db)

    demande = DemandeRH(porteur=x.jim_porteur,
                        contact_labco=x.jules_dri,
                        structure=x.labo)
    mocker.patch.object(demande, "is_valid", return_value=True)

    assert x.labo.responsables == {x.jake_directeur}

    wf = LabsterWorkflow(demande, x.jim_porteur)
    wf.start()

    assert wf.current_state() == EN_EDITION
    assert demande.active
    assert demande.editable
    assert wf.possible_transitions() == [SOUMETTRE, ABANDONNER, COMMENTER]

    wf.execute_transition(SOUMETTRE)
    assert wf.current_state() == EN_VALIDATION
    assert demande.active
    assert not demande.editable
    assert demande.current_owners() == {x.jake_directeur}
    assert demande.porteur not in demande.structure.responsables
    assert wf.possible_transitions() == [ABANDONNER]

    wf.set_actor(x.jake_directeur)
    assert wf.possible_transitions() == [
        VALIDER_DIR, REQUERIR_MODIFICATION_DIR
    ]

    wf.execute_transition(VALIDER_DIR)
    assert wf.current_state() == EN_VERIFICATION
    assert demande.active
    assert not demande.editable
    assert demande.current_owners() == {x.jules_dri}
    assert wf.possible_transitions() == [COMMENTER]

    wf.set_actor(x.jules_dri)
    assert wf.possible_transitions() == [
        ACCUSER_RECEPTION,
        CONFIRMER_RECEVABILITE_DGRTT,
        REQUERIR_MODIFICATION_DGRTT,
        REJETER_DGRTT,
        COMMENTER,
    ]

    wf.execute_transition(ACCUSER_RECEPTION)
    assert wf.possible_transitions() == [
        CONFIRMER_RECEVABILITE_DGRTT,
        REQUERIR_MODIFICATION_DGRTT,
        REJETER_DGRTT,
        COMMENTER,
    ]

    wf.execute_transition(CONFIRMER_RECEVABILITE_DGRTT)
    assert wf.current_state() == EN_INSTRUCTION
    assert demande.active
    assert not demande.editable
    assert demande.current_owners() == {x.jules_dri}
    assert wf.possible_transitions() == [
        CONFIRMER_FINALISATION_DGRTT,
        REQUERIR_MODIFICATION_DGRTT,
        REJETER_DGRTT,
        COMMENTER,
    ]

    wf.execute_transition(CONFIRMER_FINALISATION_DGRTT)
    assert wf.current_state() == TRAITEE
    assert not demande.active
    assert not demande.editable
    assert demande.current_owners() == set()
    assert wf.possible_transitions() == [DESARCHIVER]

    demande.id = None
Exemple #7
0
 def get_workflow(self, user: Profile | None = None) -> LabsterWorkflow:
     return LabsterWorkflow(self, user)