grenoble-gru: ignore string values for PAV "adresse" field (#52527)

This commit is contained in:
Serghei Mihai 2021-03-30 16:54:17 +02:00
parent 979e7e60f7
commit 42b061105f
3 changed files with 20 additions and 2 deletions

View File

@ -211,10 +211,13 @@ class GrenobleGRU(BaseResource):
@endpoint(perm='can_access', description=_('Lists PAVs'))
def pavs(self, request, *args, **kwargs):
response = self.request('ws_recuperation_pav.php')
data = response.json()
for item in data:
data = []
for item in response.json():
if not isinstance(item['adresse'], dict):
continue
item['id'] = str(item['id'])
item['text'] = '{numero_voie}, {nom_voie}, {commune}'.format(**item['adresse'])
data.append(item)
return {'data': data}
@endpoint(name='create-demand', perm='can_access', methods=['post'], description=_('Create a demand'))

View File

@ -138,5 +138,19 @@
"id": 61,
"actif": true
}
},
{
"id": 8,
"numero": "9",
"actif": true,
"adresse": "None",
"secteur": {
"libelle": "Grand Sud"
},
"Type de Dysfonctionnement": {
"libelle": "PAV A\u00e9rien Verre",
"id": 61,
"actif": true
}
}
]

View File

@ -368,6 +368,7 @@ def test_get_pavs(app, setup):
)
)
assert response.json['err'] == 0
assert len(response.json['data']) == 7
for item in response.json['data']:
assert isinstance(item['id'], str)
assert item['text']