astregs: add get-dossier endpoint (#65816)

This commit is contained in:
Emmanuel Cazenave 2022-06-01 15:48:12 +02:00
parent 800095112e
commit fe3343ea7f
3 changed files with 159 additions and 0 deletions

View File

@ -917,6 +917,23 @@ class AstreGS(BaseResource):
data.append(tiers_data)
return {'data': data}
@endpoint(
name='get-dossier',
perm='can_access',
description=_('Get Dossier'),
parameters={
'CodeDossier': {'example_value': '2021-0004933'},
'organism': {'description': _('Organisme'), 'example_value': 'NOMDEVILLE'},
'budget': {'description': _('Budget'), 'example_value': '01'},
'exercice': {'description': _('Exercice'), 'example_value': '2022'},
},
)
def get_dossier(self, request, CodeDossier, **kwargs):
self._set_context(kwargs)
payload = {'CodeDossier': CodeDossier}
r = self.call('Dossier', 'Chargement', DossierCle=payload)
return {'data': serialize_object(r)}
class Link(models.Model):
resource = models.ForeignKey(AstreGS, on_delete=models.CASCADE)

View File

@ -0,0 +1,122 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:chargementResponse xmlns:ns1="http://gfi.astre.webservices/gad/dossier">
<ns1:response>
<ns1:DossierReturn>
<ns1:CodeDossier>2021-1234</ns1:CodeDossier>
<ns1:Exercice>2021</ns1:Exercice>
<ns1:GestionCourrier/>
<ns1:ArticleLib/>
<ns1:Libelle>Libelle</ns1:Libelle>
<ns1:LibelleCourt>Libelle court</ns1:LibelleCourt>
<ns1:ModGestion>1</ns1:ModGestion>
<ns1:CodeSession>RT-2021-01-25</ns1:CodeSession>
<ns1:LicSession>RT-2021-01-25</ns1:LicSession>
<ns1:CodeDossierCommun/>
<ns1:LibelleDossierCommun/>
<ns1:DateSession>25/01/2021</ns1:DateSession>
<ns1:CodeZonage/>
<ns1:LibelleZonage/>
<ns1:OpMere xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:PhMere xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Phase>2104932</ns1:Phase>
<ns1:LicPhase>CREHANGE - SUBVENTION FONCTION</ns1:LicPhase>
<ns1:CodeServiceGestionnaire>M000</ns1:CodeServiceGestionnaire>
<ns1:LibelleServiceGestionnaire>DDCA - DLPB</ns1:LibelleServiceGestionnaire>
<ns1:CodeServiceUtilisateur>M000</ns1:CodeServiceUtilisateur>
<ns1:LibelleServiceUtilisateur>DDCA - DLPB</ns1:LibelleServiceUtilisateur>
<ns1:TypeAide>F</ns1:TypeAide>
<ns1:CodeAide>SUB-010203</ns1:CodeAide>
<ns1:LibelleAide>Libelle Aide</ns1:LibelleAide>
<ns1:Sens>D</ns1:Sens>
<ns1:CodeRegle/>
<ns1:LibelleRegle/>
<ns1:indAideNat/>
<ns1:indAssoc>0</ns1:indAssoc>
<ns1:CodManif/>
<ns1:LibManif/>
<ns1:CodeSection>F</ns1:CodeSection>
<ns1:CodeTypeSubvention>FON</ns1:CodeTypeSubvention>
<ns1:LibelleTypeSubvention>Libelle Type Subvention</ns1:LibelleTypeSubvention>
<ns1:CodeTypeIntervention>SUB</ns1:CodeTypeIntervention>
<ns1:LibelleTypeIntervention>SUBVENTION</ns1:LibelleTypeIntervention>
<ns1:CodeTypeOperation>BDP008</ns1:CodeTypeOperation>
<ns1:LibelleTypeOperation>Libelle Type Operation</ns1:LibelleTypeOperation>
<ns1:IndicateurConvention>1</ns1:IndicateurConvention>
<ns1:NbConventions>0</ns1:NbConventions>
<ns1:CodInstructeur>JOHNDOE</ns1:CodInstructeur>
<ns1:Instructeur>BARBARA, INGRID</ns1:Instructeur>
<ns1:DateDecision>25/01/2021</ns1:DateDecision>
<ns1:IndDebTrav/>
<ns1:DateDebTrav/>
<ns1:DateCaducite/>
<ns1:NumGedelib>2021_01_25_RT 33398</ns1:NumGedelib>
<ns1:CodeTiersDem>31154</ns1:CodeTiersDem>
<ns1:NomTiersDem>FOO</ns1:NomTiersDem>
<ns1:CodPostVilleDemandeur>00000 FOO</ns1:CodPostVilleDemandeur>
<ns1:CodeTiersAttrib>31152</ns1:CodeTiersAttrib>
<ns1:NomTiersAttrib>FOO</ns1:NomTiersAttrib>
<ns1:CodPostVilleAttributaire>00000 FOO</ns1:CodPostVilleAttributaire>
<ns1:Maitre_oeuvre/>
<ns1:CodeProgramme>ZZZZ200009</ns1:CodeProgramme>
<ns1:LibelleProgramme>SUBVENTION DE FONCTIONNEMENT</ns1:LibelleProgramme>
<ns1:ExEnv>2021</ns1:ExEnv>
<ns1:NumEnveloppe>69343</ns1:NumEnveloppe>
<ns1:LigneCredit>SUBV FONCT POLES DEPARTEMENT</ns1:LigneCredit>
<ns1:Operation>21I55397</ns1:Operation>
<ns1:LicOperation>FOO - SUBVENTION FONCTIONNEMENT POL</ns1:LicOperation>
<ns1:TauxTVA xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:CoutTravauxHT/>
<ns1:MontantVote>30 020,00</ns1:MontantVote>
<ns1:TauxVote/>
<ns1:MontantDemande/>
<ns1:TauxDemande/>
<ns1:CoutTravauxTTC/>
<ns1:MontantSubventionnable/>
<ns1:MontantPropose>30 020,00</ns1:MontantPropose>
<ns1:TauxPropose/>
<ns1:Mandat>0,00</ns1:Mandat>
<ns1:DateEnCours>25/08/2021</ns1:DateEnCours>
<ns1:CodeStatut>VOT</ns1:CodeStatut>
<ns1:InventTypInt/>
<ns1:NumDemande/>
<ns1:DemandesDePaiement>0,00</ns1:DemandesDePaiement>
<ns1:NoVersArc/>
<ns1:CommDossier/>
<ns1:IndDossierComplet>0</ns1:IndDossierComplet>
<ns1:IId1>1</ns1:IId1>
<ns1:IId2>2</ns1:IId2>
<ns1:IId3>3</ns1:IId3>
<ns1:IId4>4</ns1:IId4>
<ns1:IId5>5</ns1:IId5>
<ns1:IId6>6</ns1:IId6>
<ns1:IId7>7</ns1:IId7>
<ns1:IId8>8</ns1:IId8>
<ns1:IId9>9</ns1:IId9>
<ns1:IId10>10</ns1:IId10>
<ns1:VId1>25/08/2021</ns1:VId1>
<ns1:VId2/>
<ns1:VId3/>
<ns1:VId4/>
<ns1:VId5/>
<ns1:VId6/>
<ns1:VId7/>
<ns1:VId8/>
<ns1:VId9/>
<ns1:VId10/>
<ns1:IndicateurHtSubventionnable>1</ns1:IndicateurHtSubventionnable>
<ns1:CodeBudget>01</ns1:CodeBudget>
<ns1:CodDossierAssocie/>
<ns1:CodeExtranetDoss/>
<ns1:LibCourrier1/>
<ns1:LibCourrier2/>
<ns1:LibelleTypeReunion>Réunion Trimestrielle</ns1:LibelleTypeReunion>
<ns1:CommPret/>
<ns1:NoBoiteArc/>
<ns1:DateCreation>25/08/2021</ns1:DateCreation>
<ns1:DateMaj>25/08/2021</ns1:DateMaj>
</ns1:DossierReturn>
</ns1:response>
</ns1:chargementResponse>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -808,6 +808,26 @@ def test_search_tiers_by_rib_no_result(mocked_post, mocked_get, connector, app):
assert len(resp.json['data']) == 0
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_get_dossier(mocked_post, mocked_get, connector, app):
mocked_get.return_value = mock.Mock(content=get_xml_file('Dossier.wsdl'))
mocked_post.return_value = mock.Mock(
content=get_xml_file('DossierResponse.xml'),
headers={'Content-Type': 'text/xml'},
status_code=200,
)
params = {'CodeDossier': '2021-1234'}
resp = app.get('/astregs/test/get-dossier', params=params)
assert resp.json['err'] == 0
assert resp.json['data']
data = resp.json['data']
assert data['Libelle'] == 'Libelle'
assert data['LibelleCourt'] == 'Libelle court'
assert data['CodeStatut'] == 'VOT'
@mock.patch('passerelle.apps.astregs.models.serialize_object')
def test_context_overloading(mocked_serialize_object, connector, app, monkeypatch):
mock_operation_result = mock.Mock(liste=False, EncodeKeyContact=False)