diff --git a/passerelle/apps/sivin/models.py b/passerelle/apps/sivin/models.py index 54d8fd36..be0544f6 100644 --- a/passerelle/apps/sivin/models.py +++ b/passerelle/apps/sivin/models.py @@ -84,6 +84,8 @@ class Resource(BaseResource): return resp.json() def get_infos_by_immat(self, endpoint, immat, codesra=None): + # remove dashes / spaces in immat to avoid lookup issues + immat = immat.strip().replace('-', '').replace(' ', '').upper() payload = {'immat': immat} if codesra is not None: payload['codesra'] = codesra diff --git a/tests/test_sivin.py b/tests/test_sivin.py index fb0810bf..fecbbb4a 100644 --- a/tests/test_sivin.py +++ b/tests/test_sivin.py @@ -146,6 +146,7 @@ def test_get_details_by_vin(mocked_post, app, conn): kwargs={'connector': 'sivin', 'endpoint': 'consultervehiculeparvin', 'slug': conn.slug}, ) resp = app.get(url, params={'apikey': 'sivinkey', 'vin': 'VF1BA0E0514143067'}).json + assert mocked_post.call_count == 2 assert not resp['err'] assert resp['data'] == VEHICLE_DETAILS @@ -183,8 +184,9 @@ def test_get_vehicle_theorical_finition(mocked_post, app, conn): 'generic-endpoint', kwargs={'connector': 'sivin', 'endpoint': 'consulterfinitiontheoriqueparimmat', 'slug': conn.slug}, ) - resp = app.get(url, params={'apikey': 'sivinkey', 'immat': '01XT0747'}).json + resp = app.get(url, params={'apikey': 'sivinkey', 'immat': '01-xT0 747'}).json assert mocked_post.call_count == 2 + assert mocked_post.mock_calls[-1].kwargs['json'] == {'immat': '01XT0747'} assert not resp['err'] assert resp['data'] == VEHICLE_THEORICAL_FINITION