solis-afi-mss: provide quantity to demand help WS (#79327)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4ce087b6ef
commit
bd388e42a6
|
@ -103,6 +103,11 @@ DEMAND_SCHEMA = {
|
|||
'description': 'Invoice amount',
|
||||
'type': 'string',
|
||||
},
|
||||
'quantitePriseEnCharge': {
|
||||
'description': 'Quantity',
|
||||
'type': 'string',
|
||||
'pattern': r'^[0-9]*$',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -403,6 +408,8 @@ class SolisAfiMss(BaseResource, HTTPResource):
|
|||
|
||||
post_data['indexAgent'] = str(results['index'])
|
||||
post_data['individusConcernes'] = related_persons
|
||||
if not post_data.get('quantitePriseEnCharge'):
|
||||
post_data['quantitePriseEnCharge'] = '0'
|
||||
response = self.request(self.base_url + 'afi/aide/deposer/', json=post_data)
|
||||
return {'data': response}
|
||||
|
||||
|
|
|
@ -680,6 +680,52 @@ def test_demand_help(mocked_post, mocked_get, app, connector, response1, respons
|
|||
'dateDebut': '2020-07-15',
|
||||
'dateFin': '2020-07-31',
|
||||
'montantFacture': '2222.22',
|
||||
'quantitePriseEnCharge': '0',
|
||||
},
|
||||
)
|
||||
]
|
||||
data = json.loads(response2.content)
|
||||
data.pop('err')
|
||||
data.pop('err_desc')
|
||||
assert resp.json == {'err': 0, 'data': data}
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
@pytest.mark.parametrize(
|
||||
'response1, response2',
|
||||
[
|
||||
(RECHERCHE_PAR_EMAIL_4, DEPOSER_4),
|
||||
],
|
||||
)
|
||||
def test_demand_help_with_quantity(mocked_post, mocked_get, app, connector, response1, response2):
|
||||
mocked_get.side_effect = [response1]
|
||||
mocked_post.side_effect = [response2]
|
||||
endpoint = get_endpoint('demand-help')
|
||||
|
||||
payload = {
|
||||
'codeTypeAide': '24',
|
||||
'natureTypeAide': 'A',
|
||||
'individusConcernes': '388407:388408',
|
||||
'dateDebut': '2020-07-15',
|
||||
'dateFin': '2020-07-31',
|
||||
'montantFacture': '2222.22',
|
||||
'quantitePriseEnCharge': '2',
|
||||
}
|
||||
resp = app.post_json(endpoint + '?email=foo@dummy.org', params=payload)
|
||||
assert mocked_post.mock_calls == [
|
||||
mock.call(
|
||||
'https://solis-afi-mss.example.net/afi/aide/deposer/',
|
||||
headers={'Accept': 'application/json'},
|
||||
json={
|
||||
'indexAgent': '388405',
|
||||
'codeTypeAide': '24',
|
||||
'natureTypeAide': 'A',
|
||||
'individusConcernes': [{'indexIndividu': '388407'}, {'indexIndividu': '388408'}],
|
||||
'dateDebut': '2020-07-15',
|
||||
'dateFin': '2020-07-31',
|
||||
'montantFacture': '2222.22',
|
||||
'quantitePriseEnCharge': '2',
|
||||
},
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue