1382 |
1382 |
'ENCAISSE': '0.00',
|
1383 |
1383 |
'ECHEANCE': '2020-01-04',
|
1384 |
1384 |
'EMISSION': '2019-12-12',
|
1385 |
1385 |
'EXISTEPDF': False,
|
1386 |
1386 |
}
|
1387 |
1387 |
},
|
1388 |
1388 |
},
|
1389 |
1389 |
]
|
|
1390 |
|
|
1391 |
|
|
1392 |
def test_invoice_endpoint_axel_error(app, resource):
|
|
1393 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
1394 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.get_factures_a_payer') as operation:
|
|
1395 |
operation.side_effect = AxelError('FooBar')
|
|
1396 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-42?NameID=yyy')
|
|
1397 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
|
1398 |
assert resp.json['err'] == 'error'
|
|
1399 |
|
|
1400 |
|
|
1401 |
def test_invoice_endpoint_bad_request(app, resource):
|
|
1402 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
1403 |
with mock_data(None, 'GetListFactures'):
|
|
1404 |
resp = app.get(
|
|
1405 |
'/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-42?NameID=yyy&nb_mounts_limit=not_a_number',
|
|
1406 |
status=400,
|
|
1407 |
)
|
|
1408 |
assert resp.json['err_desc'] == "nb_mounts_limit must be an integer"
|
|
1409 |
assert resp.json['err'] == 'bad-request'
|
|
1410 |
|
|
1411 |
content = '''<PORTAIL>
|
|
1412 |
<GETFACTURESAPAYER>
|
|
1413 |
<CODE>-3</CODE>
|
|
1414 |
</GETFACTURESAPAYER>
|
|
1415 |
</PORTAIL>'''
|
|
1416 |
with mock_data(content, 'GetFacturesaPayer'):
|
|
1417 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-42?NameID=yyy')
|
|
1418 |
assert resp.json['err_desc'] == "Wrong get-invoices status"
|
|
1419 |
assert resp.json['err'] == 'get-invoices-code-error--3'
|
|
1420 |
|
|
1421 |
content = '''<PORTAIL>
|
|
1422 |
<GETLISTFACTURES>
|
|
1423 |
<CODE>-3</CODE>
|
|
1424 |
</GETLISTFACTURES>
|
|
1425 |
</PORTAIL>'''
|
|
1426 |
with mock_data(content, 'GetListFactures'):
|
|
1427 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-42?NameID=yyy')
|
|
1428 |
assert resp.json['err_desc'] == "Wrong get-historical-invoices status"
|
|
1429 |
assert resp.json['err'] == 'get-historical-invoices-code-error--3'
|
|
1430 |
|
|
1431 |
|
|
1432 |
def test_invoice_endpoint_no_result(app, resource):
|
|
1433 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-42?NameID=yyy')
|
|
1434 |
assert resp.json['err_desc'] == "Person not found"
|
|
1435 |
assert resp.json['err'] == 'not-found'
|
|
1436 |
|
|
1437 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
1438 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/invoices.xml')
|
|
1439 |
with open(filepath) as xml:
|
|
1440 |
invoices = xml.read()
|
|
1441 |
content = (
|
|
1442 |
'''<PORTAIL>
|
|
1443 |
<GETFACTURESAPAYER>
|
|
1444 |
%s
|
|
1445 |
</GETFACTURESAPAYER>
|
|
1446 |
</PORTAIL>'''
|
|
1447 |
% invoices
|
|
1448 |
)
|
|
1449 |
with mock_data(content, 'GetFacturesaPayer'):
|
|
1450 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-35?NameID=yyy')
|
|
1451 |
assert resp.json['err_desc'] == "Invoice not found"
|
|
1452 |
assert resp.json['err'] == 'not-found'
|
|
1453 |
content = (
|
|
1454 |
'''<PORTAIL>
|
|
1455 |
<GETLISTFACTURES>
|
|
1456 |
%s
|
|
1457 |
</GETLISTFACTURES>
|
|
1458 |
</PORTAIL>'''
|
|
1459 |
% invoices
|
|
1460 |
)
|
|
1461 |
with mock_data(content, 'GetListFactures'):
|
|
1462 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-44?NameID=yyy')
|
|
1463 |
assert resp.json['err_desc'] == "Invoice not found"
|
|
1464 |
assert resp.json['err'] == 'not-found'
|
|
1465 |
|
|
1466 |
|
|
1467 |
def test_invoice_endpoint(app, resource):
|
|
1468 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
|
1469 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/invoices.xml')
|
|
1470 |
with open(filepath) as xml:
|
|
1471 |
invoices = xml.read()
|
|
1472 |
content = (
|
|
1473 |
'''<PORTAIL>
|
|
1474 |
<GETFACTURESAPAYER>
|
|
1475 |
%s
|
|
1476 |
</GETFACTURESAPAYER>
|
|
1477 |
</PORTAIL>'''
|
|
1478 |
% invoices
|
|
1479 |
)
|
|
1480 |
with mock_data(content, 'GetFacturesaPayer'):
|
|
1481 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-42?NameID=yyy')
|
|
1482 |
assert resp.json['err'] == 0
|
|
1483 |
assert resp.json['data'] == {
|
|
1484 |
'id': 'XXX-42',
|
|
1485 |
'display_id': '42',
|
|
1486 |
'label': 'PRESTATIONS PERISCOLAIRES SEPTEMBRE-OCTOBRE 2019',
|
|
1487 |
'amount': '4.94',
|
|
1488 |
'total_amount': '44.94',
|
|
1489 |
'amount_paid': '40.00',
|
|
1490 |
'online_payment': True,
|
|
1491 |
'created': '2019-11-12',
|
|
1492 |
'pay_limit_date': '2019-12-04',
|
|
1493 |
'has_pdf': True,
|
|
1494 |
'paid': False,
|
|
1495 |
'vendor': {
|
|
1496 |
'caluire-axel': {
|
|
1497 |
'IDFACTURE': 42,
|
|
1498 |
'MONTANT': '44.94',
|
|
1499 |
'ENCAISSE': '40.00',
|
|
1500 |
'FACTURATION': 'PRESTATIONS PERISCOLAIRES SEPTEMBRE-OCTOBRE 2019',
|
|
1501 |
'ECHEANCE': '2019-12-04',
|
|
1502 |
'EMISSION': '2019-11-12',
|
|
1503 |
'EXISTEPDF': True,
|
|
1504 |
}
|
|
1505 |
},
|
|
1506 |
}
|
|
1507 |
|
|
1508 |
content = (
|
|
1509 |
'''<PORTAIL>
|
|
1510 |
<GETLISTFACTURES>
|
|
1511 |
%s
|
|
1512 |
</GETLISTFACTURES>
|
|
1513 |
</PORTAIL>'''
|
|
1514 |
% invoices
|
|
1515 |
)
|
|
1516 |
with mock_data(content, 'GetListFactures'):
|
|
1517 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-42?NameID=yyy')
|
|
1518 |
assert resp.json['err'] == 0
|
|
1519 |
assert resp.json['data'] == {
|
|
1520 |
'id': 'historical-XXX-42',
|
|
1521 |
'display_id': '42',
|
|
1522 |
'label': 'PRESTATIONS PERISCOLAIRES SEPTEMBRE-OCTOBRE 2019',
|
|
1523 |
'amount': 0,
|
|
1524 |
'total_amount': '44.94',
|
|
1525 |
'online_payment': False,
|
|
1526 |
'pay_limit_date': '',
|
|
1527 |
'has_pdf': True,
|
|
1528 |
'paid': False,
|
|
1529 |
'vendor': {
|
|
1530 |
'caluire-axel': {
|
|
1531 |
'IDFACTURE': 42,
|
|
1532 |
'MONTANT': '44.94',
|
|
1533 |
'ENCAISSE': '40.00',
|
|
1534 |
'FACTURATION': 'PRESTATIONS PERISCOLAIRES SEPTEMBRE-OCTOBRE 2019',
|
|
1535 |
'ECHEANCE': '2019-12-04',
|
|
1536 |
'EMISSION': '2019-11-12',
|
|
1537 |
'EXISTEPDF': True,
|
|
1538 |
},
|
|
1539 |
},
|
|
1540 |
}
|
1390 |
|
-
|