toulouse_maelis: ease retrieving maelis ids on nursery (#74446) #106

Merged
nroche merged 2 commits from wip/74446-parsifal-detail-nursery-referential into main 2023-03-29 10:44:44 +02:00
2 changed files with 44 additions and 0 deletions

View File

@ -3223,6 +3223,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
nurseries = [n for n in nurseries if n['activityType']['code'] == activity_type]
if code_psu:
nurseries = [n for n in nurseries if code_psu in [u['typeAcc'] for u in n['unitList']]]
for item in nurseries:
item['activity_id'] = item['idActivity']
item['place_id'] = item['place']['idPlace']
item['unit_ids'] = {}
for unit in item['unitList'] or []:
item['unit_ids'][unit['typeAcc']] = unit['idUnit']
if code_psu:
item['unit_id'] = item['unit_ids'].get(code_psu)
return {'data': nurseries}
@endpoint(

View File

@ -7601,6 +7601,41 @@ def test_read_nursery_list(con, app):
resp = app.get(url, params={'code_psu': 'REGULAR'})
assert len(resp.json['data']) == 9
assert resp.json['data'][0] == {
'id': 'M10000000001',
'activity_id': 'M10000000001',
'unit_id': 'M10053212402',
'place_id': 'M10053212401',
'unit_ids': {'OCCASIONAL': 'M10053212403', 'REGULAR': 'M10053212402'},
'obs1': 'Quartier 1.2',
'obs2': 'Secteur 1',
'text': 'CC AMIDONNIERS',
'place': {
'address': {
'num': 29,
'town': 'TOULOUSE',
'street1': 'ALL DE BRIENNE',
'street2': None,
'zipcode': '31000',
'idStreet': None,
},
'idPlace': 'M10053212401',
'libelle': 'CC AMIDONNIERS',
'latitude': 43.606099,
'libelle2': None,
'longitude': 1.430282,
},
'libelle': 'CC AMIDONNIERS',
'libelle2': None,
'manager1': {'phone': '0561615590', 'poste': 'CCAS', 'lastname': 'THOMAS', 'firstname': 'GUYLAINE'},
'manager2': None,
'unitList': [
{'idUnit': 'M10053212402', 'libelle': 'CC AMIDONNIERS - Réguliers', 'typeAcc': 'REGULAR'},
{'idUnit': 'M10053212403', 'libelle': 'CC AMIDONNIERS - Occasionnels', 'typeAcc': 'OCCASIONAL'},
],
'idActivity': 'M10000000001',
'activityType': {'code': 'CRECHCO', 'libelle': 'Crèche collective'},
}
def test_get_nursery_geojson(con, app):