toulouse-foederis: fix querying 'emploi' datasource with parent (#79938)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8cdf3dcae2
commit
9d78d8fcf3
|
@ -361,7 +361,14 @@ class Resource(BaseResource, HTTPResource):
|
|||
data = [{'id': r['id'], 'text': r['name']} for r in results]
|
||||
else:
|
||||
parent_fkey = self.REFERENTIELS_FKEYS[parent]
|
||||
data = [{'id': r['id'], 'text': r['name'], 'parents': r[parent_fkey]} for r in results]
|
||||
|
||||
def _get_parents(item):
|
||||
parent_field = item[parent_fkey]
|
||||
if isinstance(parent_field, int):
|
||||
return [parent_field]
|
||||
return parent_field
|
||||
|
||||
data = [{'id': r['id'], 'text': r['name'], 'parents': _get_parents(r)} for r in results]
|
||||
|
||||
self.documents.update_or_create(defaults={'data': data}, external_id=document_id)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -263,14 +263,16 @@ class TestEndpoints:
|
|||
}
|
||||
|
||||
def test_data_source_with_parent(self, app):
|
||||
response = app.get('/toulouse-foederis/foederis/ds/emploi/?parent=5776416')
|
||||
response = app.get('/toulouse-foederis/foederis/ds/emploi/?parent=6131210')
|
||||
assert response.json['err'] == 0
|
||||
assert response.json['last_update']
|
||||
assert {d['text'] for d in response.json['data']} == {
|
||||
'CHARGE OU CHARGEE DU DEVELOPPEMENT TERRITORIAL',
|
||||
'DEVELOPPEUR OU DEVELOPPEUSE ECONOMIQUE',
|
||||
'REFERENT OU REFERENTE DE QUARTIER',
|
||||
'CHEF OU CHEFFE DE PROJET ACTIONS EUROPEENNES ET INTERNATIONALES',
|
||||
"CHARGE OU CHARGEE D'OPERATIONS AMENAGEMENT",
|
||||
'CHARGE OU CHARGEE DE MOBILITE',
|
||||
'CHARGE OU CHARGEE DE LA SECURITE ROUTIERE',
|
||||
'CHARGE OU CHARGEE D ANIMATION PLUI-H ET RLPI',
|
||||
'CHARGE OU CHARGEE PLANIFICATION PROGRAMMATION',
|
||||
"INSTRUCTEUR OU INSTRUCTRICE DES AUTORISATIONS D'URBANISME, ENSEIGNES ET TLPE",
|
||||
}
|
||||
|
||||
def test_announce(self, app):
|
||||
|
|
Loading…
Reference in New Issue