astregs: add endpoints to update and delection indana indicator (#35627)
This commit is contained in:
parent
10aac44184
commit
7a2cf3cb48
|
@ -260,6 +260,28 @@ INDANA_SCHEMA = {
|
|||
}
|
||||
}
|
||||
|
||||
INDANA_DELETION_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-03/schema#",
|
||||
"title": "AstreGS INDANA indicator",
|
||||
"description": "",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"CodeDossier": {
|
||||
"type": "string",
|
||||
"required": True
|
||||
},
|
||||
"CodeInd_1": {
|
||||
"type": "string",
|
||||
"required": True
|
||||
},
|
||||
"AnneeInd_1": {
|
||||
"type": "string",
|
||||
"required": True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class AstreGS(BaseResource):
|
||||
wsdl_base_url = models.URLField(_('Webservices base URL'))
|
||||
|
@ -588,6 +610,38 @@ class AstreGS(BaseResource):
|
|||
return {'data': serialize_object(r)}
|
||||
|
||||
|
||||
@endpoint(name='update-indana-indicator', perm='can_access',
|
||||
post={'description': _('Update indana indicator'),
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': INDANA_SCHEMA
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
def update_indana_indicator(self, request, post_data):
|
||||
r = self.call('DossierIndicateur', 'Modification',
|
||||
DossierIndicateur=post_data
|
||||
)
|
||||
return {'data': serialize_object(r)}
|
||||
|
||||
|
||||
@endpoint(name='delete-indana-indicator', perm='can_access',
|
||||
post={'description': _('Delete indana indicator'),
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': INDANA_DELETION_SCHEMA
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
def delete_indana_indicator(self, request, post_data):
|
||||
r = self.call('DossierIndicateur', 'Suppression',
|
||||
DossierIndicateurCle=post_data
|
||||
)
|
||||
return {'data': serialize_object(r)}
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(AstreGS)
|
||||
name_id = models.CharField(max_length=32)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:modificationResponse xmlns:ns1="http://gfi.astre.webservices/gad/dossierindicateur"><ns1:response><ns1:DossierIndicateurReturn><ns1:CodeDossier>2019_06407</ns1:CodeDossier><ns1:CodeInd_1>501</ns1:CodeInd_1><ns1:AnneeInd_1>2019</ns1:AnneeInd_1><ns1:ValInd_1>N</ns1:ValInd_1><ns1:IndAide>Non</ns1:IndAide></ns1:DossierIndicateurReturn></ns1:response></ns1:modificationResponse></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:suppressionResponse xmlns:ns1="http://gfi.astre.webservices/gad/dossierindicateur"><ns1:response><ns1:DossierIndicateurReturn><ns1:CodeDossier>2019_06407</ns1:CodeDossier><ns1:CodeInd_1>501</ns1:CodeInd_1><ns1:AnneeInd_1>2019</ns1:AnneeInd_1><ns1:ValInd_1>N</ns1:ValInd_1><ns1:IndAide>Non</ns1:IndAide></ns1:DossierIndicateurReturn></ns1:response></ns1:suppressionResponse></soapenv:Body></soapenv:Envelope>
|
|
@ -470,3 +470,50 @@ def test_create_indana_indicator(mocked_post, mocked_get, connector, app):
|
|||
assert data['AnneeInd_1'] == '2019'
|
||||
assert data['ValInd_1'] == 'O'
|
||||
assert data['IndAide'] == 'Non'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_indana_indicator(mocked_post, mocked_get, connector, app):
|
||||
mocked_get.return_value = mock.Mock(content=get_xml_file('DossierIndicateur.wsdl'))
|
||||
mocked_post.return_value = mock.Mock(content=get_xml_file('DossierIndicateurModificationResponse.xml'),
|
||||
headers={'Content-Type': 'text/xml'},
|
||||
status_code=200)
|
||||
payload = {
|
||||
'CodeDossier': '2019_06407',
|
||||
'CodeInd_1': '501',
|
||||
'AnneeInd_1': '2019',
|
||||
'ValInd_1': 'N'
|
||||
}
|
||||
resp = app.post_json('/astregs/test/update-indana-indicator', params=payload)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data']
|
||||
data = resp.json['data']
|
||||
assert data['CodeDossier'] == '2019_06407'
|
||||
assert data['CodeInd_1'] == '501'
|
||||
assert data['AnneeInd_1'] == '2019'
|
||||
assert data['ValInd_1'] == 'N'
|
||||
assert data['IndAide'] == 'Non'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_delete_indana_indicator(mocked_post, mocked_get, connector, app):
|
||||
mocked_get.return_value = mock.Mock(content=get_xml_file('DossierIndicateur.wsdl'))
|
||||
mocked_post.return_value = mock.Mock(content=get_xml_file('DossierIndicateurSuppressionResponse.xml'),
|
||||
headers={'Content-Type': 'text/xml'},
|
||||
status_code=200)
|
||||
payload = {
|
||||
'CodeDossier': '2019_06407',
|
||||
'CodeInd_1': '501',
|
||||
'AnneeInd_1': '2019'
|
||||
}
|
||||
resp = app.post_json('/astregs/test/delete-indana-indicator', params=payload)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data']
|
||||
data = resp.json['data']
|
||||
assert data['CodeDossier'] == '2019_06407'
|
||||
assert data['CodeInd_1'] == '501'
|
||||
assert data['AnneeInd_1'] == '2019'
|
||||
assert data['ValInd_1'] == 'N'
|
||||
assert data['IndAide'] == 'Non'
|
||||
|
|
Loading…
Reference in New Issue