3284 |
3284 |
with mock_data(content, 'GetFacturesaPayer'):
|
3285 |
3285 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.set_paiement') as operation:
|
3286 |
3286 |
operation.side_effect = AxelError('FooBar')
|
3287 |
3287 |
resp = app.post_json(
|
3288 |
3288 |
'/caluire-axel/test/regie/MAREGIE/invoice/XXX-42/pay?NameID=yyy', params=payload
|
3289 |
3289 |
)
|
3290 |
3290 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
3291 |
3291 |
assert resp.json['err'] == 'error'
|
|
3292 |
for key in ('xml_request', 'xml_response', 'regie_id', 'family_id', 'invoice', 'post_data', 'kwargs'):
|
|
3293 |
assert key in resp.json['data'].keys()
|
3292 |
3294 |
|
3293 |
3295 |
content2 = '''
|
3294 |
3296 |
<PORTAIL>
|
3295 |
3297 |
<SETPAIEMENT>
|
3296 |
3298 |
<CODE>-3</CODE>
|
3297 |
3299 |
</SETPAIEMENT>
|
3298 |
3300 |
</PORTAIL>'''
|
3299 |
3301 |
with mock.patch('passerelle.contrib.caluire_axel.models.CaluireAxel.soap_client') as client:
|
... | ... | |
3330 |
3332 |
% xml.read()
|
3331 |
3333 |
)
|
3332 |
3334 |
with mock_data(content, 'GetFacturesaPayer'):
|
3333 |
3335 |
resp = app.post_json('/caluire-axel/test/regie/MAREGIE/invoice/XXX-35/pay?NameID=yyy', params=payload)
|
3334 |
3336 |
assert resp.json['err_desc'] == "Invoice not found"
|
3335 |
3337 |
assert resp.json['err'] == 'not-found'
|
3336 |
3338 |
|
3337 |
3339 |
|
|
3340 |
def test_pay_invoice_endpoint_wrong_response(app, resource):
|
|
3341 |
payload = {
|
|
3342 |
'transaction_date': '2021-06-15T12:00:00',
|
|
3343 |
'transaction_id': 'foo',
|
|
3344 |
}
|
|
3345 |
with mock.patch(
|
|
3346 |
'passerelle.contrib.caluire_axel.models.CaluireAxel.get_invoice',
|
|
3347 |
return_value={'amount': '44.9'},
|
|
3348 |
):
|
|
3349 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.set_paiement') as operation:
|
|
3350 |
operation.return_value = OperationResult(
|
|
3351 |
json_response={'DATA': {'PORTAIL': {}}},
|
|
3352 |
xml_request='',
|
|
3353 |
xml_response='',
|
|
3354 |
)
|
|
3355 |
resp = app.post_json(
|
|
3356 |
'/caluire-axel/test/regie/MAREGIE/invoice/XXX-42/pay?NameID=yyy',
|
|
3357 |
params=payload,
|
|
3358 |
status=500,
|
|
3359 |
)
|
|
3360 |
assert resp.json['err'] == 'pay-invoice-code-response-error'
|
|
3361 |
assert resp.json['err_desc'] == 'Wrong pay-invoice response'
|
|
3362 |
for key in 'regie_id', 'family_id', 'invoice', 'post_data', 'kwargs', 'result':
|
|
3363 |
assert key in resp.json['data'].keys()
|
|
3364 |
|
|
3365 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.set_paiement') as operation:
|
|
3366 |
operation.return_value = OperationResult(
|
|
3367 |
json_response={'DATA': {'PORTAIL': {'SETPAIEMENT': {'CODE': 'oups'}}}},
|
|
3368 |
xml_request='',
|
|
3369 |
xml_response='',
|
|
3370 |
)
|
|
3371 |
resp = app.post_json(
|
|
3372 |
'/caluire-axel/test/regie/MAREGIE/invoice/XXX-42/pay?NameID=yyy',
|
|
3373 |
params=payload,
|
|
3374 |
status=500,
|
|
3375 |
)
|
|
3376 |
assert resp.json['err'] == 'pay-invoice-code-response-error'
|
|
3377 |
assert resp.json['err_desc'] == 'Wrong pay-invoice response'
|
|
3378 |
for key in 'regie_id', 'family_id', 'invoice', 'post_data', 'kwargs', 'result':
|
|
3379 |
assert key in resp.json['data'].keys()
|
|
3380 |
|
|
3381 |
|
3338 |
3382 |
def test_pay_invoice_endpoint(app, resource):
|
3339 |
3383 |
payload = {
|
3340 |
3384 |
'transaction_date': '2021-06-15T12:00:00',
|
3341 |
3385 |
'transaction_id': 'foo',
|
3342 |
3386 |
}
|
3343 |
3387 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
3344 |
3388 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/invoices.xml')
|
3345 |
3389 |
with open(filepath) as xml:
|
3346 |
|
-
|