21 |
21 |
|
22 |
22 |
from django.core.urlresolvers import reverse
|
23 |
23 |
|
|
24 |
import requests
|
|
25 |
|
24 |
26 |
from passerelle.apps.api_particulier.models import APIParticulier
|
25 |
27 |
|
26 |
28 |
from utils import make_resource, endpoint_get
|
... | ... | |
154 |
156 |
return response(500, 'something bad happened', request=request)
|
155 |
157 |
|
156 |
158 |
|
|
159 |
@urlmatch(netloc=r'^particulier.*\.api\.gouv\.fr$')
|
|
160 |
def api_particulier_connection_error(url, request):
|
|
161 |
raise requests.RequestException('connection timed-out')
|
|
162 |
|
|
163 |
|
157 |
164 |
@urlmatch(netloc=r'^particulier.*\.api\.gouv\.fr$')
|
158 |
165 |
def api_particulier_error_not_json(url, request):
|
159 |
166 |
return response(200, 'something bad happened', request=request)
|
... | ... | |
257 |
264 |
for endpoints, params in vector:
|
258 |
265 |
for endpoint in endpoints:
|
259 |
266 |
do(endpoint, params)
|
|
267 |
with HTTMock(api_particulier_connection_error):
|
|
268 |
def do(endpoint, params):
|
|
269 |
resp = endpoint_get(
|
|
270 |
'/api-particulier/test/%s' % endpoint,
|
|
271 |
app,
|
|
272 |
resource,
|
|
273 |
endpoint,
|
|
274 |
params=params)
|
|
275 |
assert resp.status_code == 200
|
|
276 |
assert resp.json['err'] == 1
|
|
277 |
assert resp.json['err_desc'] == 'API-particulier platform "test" connection error: connection timed-out'
|
|
278 |
vector = [
|
|
279 |
(['impots_svair', 'impots_adresse'], {
|
|
280 |
'numero_fiscal': 12,
|
|
281 |
'reference_avis': 15,
|
|
282 |
}),
|
|
283 |
(['caf_famille'], {
|
|
284 |
'code_postal': 12,
|
|
285 |
'numero_allocataire': 15
|
|
286 |
}),
|
|
287 |
]
|
|
288 |
for endpoints, params in vector:
|
|
289 |
for endpoint in endpoints:
|
|
290 |
do(endpoint, params)
|
260 |
291 |
|
261 |
292 |
|
262 |
293 |
def test_impots_svair(app, resource, mock_api_particulier):
|
... | ... | |
310 |
341 |
assert 'family allowance' in response.text
|
311 |
342 |
assert 'fiscal information' in response.text
|
312 |
343 |
assert 'fiscal address' in response.text
|
313 |
|
|
314 |
|
-
|