2815 |
2815 |
</GETFACTURESAPAYER>
|
2816 |
2816 |
</PORTAIL>'''
|
2817 |
2817 |
with mock_data(content, 'GetFacturesaPayer'):
|
2818 |
2818 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoices?NameID=yyy')
|
2819 |
2819 |
assert resp.json['err'] == 0
|
2820 |
2820 |
assert resp.json['data'] == []
|
2821 |
2821 |
|
2822 |
2822 |
|
2823 |
|
@freezegun.freeze_time('2019-12-05')
|
|
2823 |
@freezegun.freeze_time('2019-12-12')
|
2824 |
2824 |
def test_invoices_endpoint(app, resource):
|
2825 |
2825 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
2826 |
2826 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/invoices.xml')
|
2827 |
2827 |
with open(filepath) as xml:
|
2828 |
2828 |
content = (
|
2829 |
2829 |
'''
|
2830 |
2830 |
<PORTAIL>
|
2831 |
2831 |
<GETFACTURESAPAYER>
|
... | ... | |
2881 |
2881 |
'MONTANT': '44.94',
|
2882 |
2882 |
'ENCAISSE': '0.00',
|
2883 |
2883 |
'ECHEANCE': '2020-01-04',
|
2884 |
2884 |
'EMISSION': '2019-12-12',
|
2885 |
2885 |
'EXISTEPDF': False,
|
2886 |
2886 |
}
|
2887 |
2887 |
},
|
2888 |
2888 |
},
|
|
2889 |
{
|
|
2890 |
'id': 'XXX-44',
|
|
2891 |
'display_id': '44',
|
|
2892 |
'label': 'PRESTATIONS PERISCOLAIRES DECEMBRE 2019',
|
|
2893 |
'amount': '44.44',
|
|
2894 |
'total_amount': '44.44',
|
|
2895 |
'amount_paid': '0.00',
|
|
2896 |
'online_payment': False,
|
|
2897 |
'created': '2020-01-12',
|
|
2898 |
'pay_limit_date': '2020-02-04',
|
|
2899 |
'has_pdf': False,
|
|
2900 |
'paid': False,
|
|
2901 |
'vendor': {
|
|
2902 |
'caluire-axel': {
|
|
2903 |
'IDFACTURE': 44,
|
|
2904 |
'FACTURATION': 'PRESTATIONS PERISCOLAIRES DECEMBRE 2019',
|
|
2905 |
'MONTANT': '44.44',
|
|
2906 |
'ENCAISSE': '0.00',
|
|
2907 |
'ECHEANCE': '2020-02-04',
|
|
2908 |
'EMISSION': '2020-01-12',
|
|
2909 |
'EXISTEPDF': False,
|
|
2910 |
}
|
|
2911 |
},
|
|
2912 |
},
|
2889 |
2913 |
]
|
2890 |
2914 |
|
2891 |
2915 |
|
2892 |
2916 |
def test_invoices_history_endpoint_axel_error(app, resource):
|
2893 |
2917 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
2894 |
2918 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.get_list_factures') as operation:
|
2895 |
2919 |
operation.side_effect = AxelError('FooBar')
|
2896 |
2920 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoices/history?NameID=yyy')
|
... | ... | |
2995 |
3019 |
'MONTANT': '44.94',
|
2996 |
3020 |
'ENCAISSE': '0.00',
|
2997 |
3021 |
'ECHEANCE': '2020-01-04',
|
2998 |
3022 |
'EMISSION': '2019-12-12',
|
2999 |
3023 |
'EXISTEPDF': False,
|
3000 |
3024 |
}
|
3001 |
3025 |
},
|
3002 |
3026 |
},
|
|
3027 |
{
|
|
3028 |
'id': 'historical-XXX-44',
|
|
3029 |
'display_id': '44',
|
|
3030 |
'label': 'PRESTATIONS PERISCOLAIRES DECEMBRE 2019',
|
|
3031 |
'amount': 0,
|
|
3032 |
'created': '2020-01-12',
|
|
3033 |
'total_amount': '44.44',
|
|
3034 |
'online_payment': False,
|
|
3035 |
'pay_limit_date': '',
|
|
3036 |
'has_pdf': False,
|
|
3037 |
'paid': False,
|
|
3038 |
'vendor': {
|
|
3039 |
'caluire-axel': {
|
|
3040 |
'IDFACTURE': 44,
|
|
3041 |
'FACTURATION': 'PRESTATIONS PERISCOLAIRES DECEMBRE 2019',
|
|
3042 |
'MONTANT': '44.44',
|
|
3043 |
'ENCAISSE': '0.00',
|
|
3044 |
'ECHEANCE': '2020-02-04',
|
|
3045 |
'EMISSION': '2020-01-12',
|
|
3046 |
'EXISTEPDF': False,
|
|
3047 |
}
|
|
3048 |
},
|
|
3049 |
},
|
3003 |
3050 |
]
|
3004 |
3051 |
|
3005 |
3052 |
|
3006 |
3053 |
def test_invoice_endpoint_axel_error(app, resource):
|
3007 |
3054 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
3008 |
3055 |
with mock.patch('passerelle.contrib.caluire_axel.schemas.get_factures_a_payer') as operation:
|
3009 |
3056 |
operation.side_effect = AxelError('FooBar')
|
3010 |
3057 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-42?NameID=yyy')
|
... | ... | |
3068 |
3115 |
'''<PORTAIL>
|
3069 |
3116 |
<GETLISTFACTURES>
|
3070 |
3117 |
%s
|
3071 |
3118 |
</GETLISTFACTURES>
|
3072 |
3119 |
</PORTAIL>'''
|
3073 |
3120 |
% invoices
|
3074 |
3121 |
)
|
3075 |
3122 |
with mock_data(content, 'GetListFactures'):
|
3076 |
|
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-44?NameID=yyy')
|
|
3123 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/historical-XXX-41?NameID=yyy')
|
3077 |
3124 |
assert resp.json['err_desc'] == "Invoice not found"
|
3078 |
3125 |
assert resp.json['err'] == 'not-found'
|
3079 |
3126 |
|
3080 |
3127 |
|
3081 |
3128 |
@freezegun.freeze_time('2019-12-04')
|
3082 |
3129 |
def test_invoice_endpoint(app, resource):
|
3083 |
3130 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
3084 |
3131 |
filepath = os.path.join(os.path.dirname(__file__), 'data/caluire_axel/invoices.xml')
|
... | ... | |
3210 |
3257 |
% xml.read()
|
3211 |
3258 |
)
|
3212 |
3259 |
with mock_data(content, 'GetFacturesaPayer'):
|
3213 |
3260 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-35/pdf?NameID=yyy', status=404)
|
3214 |
3261 |
assert resp.json['err_desc'] == "Invoice not found"
|
3215 |
3262 |
assert resp.json['err'] == 'not-found'
|
3216 |
3263 |
|
3217 |
3264 |
with mock_data(content, 'GetFacturesaPayer'):
|
3218 |
|
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-44/pdf?NameID=yyy', status=404)
|
|
3265 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-41/pdf?NameID=yyy', status=404)
|
3219 |
3266 |
assert resp.json['err_desc'] == "Invoice not found"
|
3220 |
3267 |
assert resp.json['err'] == 'not-found'
|
3221 |
3268 |
|
3222 |
3269 |
with mock_data(content, 'GetFacturesaPayer'):
|
3223 |
3270 |
resp = app.get('/caluire-axel/test/regie/MAREGIE/invoice/XXX-43/pdf?NameID=yyy', status=404)
|
3224 |
3271 |
assert resp.json['err_desc'] == "PDF not available"
|
3225 |
3272 |
assert resp.json['err'] == 'not-available'
|
3226 |
3273 |
|
3227 |
|
-
|