sivin: normalize immat to avoid lookup issues with remote API (#67359)
This commit is contained in:
parent
3cec274259
commit
a9449c0e51
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue