23 |
23 |
|
24 |
24 |
from passerelle.apps.api_particulier.models import APIParticulier
|
25 |
25 |
|
26 |
|
from utils import make_ressource, endpoint_get
|
|
26 |
from utils import make_resource, endpoint_get
|
27 |
27 |
|
28 |
28 |
SVAIR_RESPONSE = {
|
29 |
29 |
"declarant1": {
|
... | ... | |
162 |
162 |
@urlmatch(netloc='^particulier.*\.api\.gouv\.fr$')
|
163 |
163 |
def api_particulier_error_not_found(url, request):
|
164 |
164 |
return response(404, {
|
165 |
|
'error': 'not-found',
|
|
165 |
'error': 'not_found',
|
166 |
166 |
'message': u'Les paramètres fournis sont incorrects ou ne correspondent pas à un avis'
|
167 |
167 |
}, request=request)
|
168 |
168 |
|
... | ... | |
174 |
174 |
|
175 |
175 |
|
176 |
176 |
@pytest.fixture
|
177 |
|
def ressource(db):
|
178 |
|
return make_ressource(
|
|
177 |
def resource(db):
|
|
178 |
return make_resource(
|
179 |
179 |
APIParticulier,
|
180 |
180 |
slug='test',
|
181 |
181 |
title='API Particulier Prod',
|
... | ... | |
183 |
183 |
_platform='test')
|
184 |
184 |
|
185 |
185 |
|
186 |
|
def test_error(app, ressource, mock_api_particulier):
|
|
186 |
def test_error(app, resource, mock_api_particulier):
|
187 |
187 |
with HTTMock(api_particulier_error_500):
|
188 |
188 |
def do(endpoint, params):
|
189 |
189 |
resp = endpoint_get(
|
190 |
190 |
'/api-particulier/test/%s' % endpoint,
|
191 |
191 |
app,
|
192 |
|
ressource,
|
|
192 |
resource,
|
193 |
193 |
endpoint,
|
194 |
194 |
params=params)
|
195 |
195 |
assert resp.status_code == 200
|
... | ... | |
213 |
213 |
resp = endpoint_get(
|
214 |
214 |
'/api-particulier/test/%s' % endpoint,
|
215 |
215 |
app,
|
216 |
|
ressource,
|
|
216 |
resource,
|
217 |
217 |
endpoint,
|
218 |
218 |
params=params)
|
219 |
219 |
assert resp.status_code == 200
|
... | ... | |
237 |
237 |
resp = endpoint_get(
|
238 |
238 |
'/api-particulier/test/%s' % endpoint,
|
239 |
239 |
app,
|
240 |
|
ressource,
|
|
240 |
resource,
|
241 |
241 |
endpoint,
|
242 |
242 |
params=params)
|
243 |
243 |
assert resp.status_code == 200
|
... | ... | |
258 |
258 |
do(endpoint, params)
|
259 |
259 |
|
260 |
260 |
|
261 |
|
def test_impots_svair(app, ressource, mock_api_particulier):
|
|
261 |
def test_impots_svair(app, resource, mock_api_particulier):
|
262 |
262 |
resp = endpoint_get(
|
263 |
263 |
'/api-particulier/test/impots_svair',
|
264 |
264 |
app,
|
265 |
|
ressource,
|
|
265 |
resource,
|
266 |
266 |
'impots_svair',
|
267 |
267 |
params={
|
268 |
268 |
'numero_fiscal': 12,
|
... | ... | |
272 |
272 |
assert resp.json['data']['montantImpot'] == 2165
|
273 |
273 |
|
274 |
274 |
|
275 |
|
def test_impots_adresse(app, ressource, mock_api_particulier):
|
|
275 |
def test_impots_adresse(app, resource, mock_api_particulier):
|
276 |
276 |
resp = endpoint_get(
|
277 |
277 |
'/api-particulier/test/impots_adresse',
|
278 |
278 |
app,
|
279 |
|
ressource,
|
|
279 |
resource,
|
280 |
280 |
'impots_adresse',
|
281 |
281 |
params={
|
282 |
282 |
'numero_fiscal': 12,
|
... | ... | |
286 |
286 |
assert resp.json['data']['adresses'][0]['adresse']['citycode'] == '75108'
|
287 |
287 |
|
288 |
288 |
|
289 |
|
def test_caf_famille(app, ressource, mock_api_particulier):
|
|
289 |
def test_caf_famille(app, resource, mock_api_particulier):
|
290 |
290 |
resp = endpoint_get(
|
291 |
291 |
'/api-particulier/test/caf_famille',
|
292 |
292 |
app,
|
293 |
|
ressource,
|
|
293 |
resource,
|
294 |
294 |
'caf_famille',
|
295 |
295 |
params={
|
296 |
296 |
'code_postal': '99148',
|
... | ... | |
300 |
300 |
assert resp.json['data']['adresse']['codePostalVille'] == '12345 CONDAT'
|
301 |
301 |
|
302 |
302 |
|
303 |
|
def test_detail_page(app, ressource):
|
|
303 |
def test_detail_page(app, resource):
|
304 |
304 |
response = app.get(reverse('view-connector', kwargs={
|
305 |
305 |
'connector': 'api-particulier',
|
306 |
306 |
'slug': 'test',
|