From b5f9ca52445bd2ee0ccb1f803fcb3c6c842713e9 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sun, 5 Feb 2023 15:17:55 +0100 Subject: [PATCH] toulouse-maelis: get id and text for school derog list (#74194) --- passerelle/contrib/toulouse_maelis/models.py | 10 +++- ...get_child_subscribe_school_information.xml | 59 +++++++++++++++++++ tests/test_toulouse_maelis.py | 10 +++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index 5b8aadc1..3e3ae4ec 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -2100,7 +2100,15 @@ class ToulouseMaelis(BaseResource, HTTPResource): response = self.call( 'Family', 'getChildSubscribeSchoolInformation', getFamilySubscribeSchoolInfoRequestBean=data ) - return {'data': serialize_object(response)} + data = serialize_object(response) + if data['childSubscribeSchoolInformation'].get('subscribeSchoolInformation'): + schools = data['childSubscribeSchoolInformation']['subscribeSchoolInformation'].get( + 'derogSchoolList' + ) + for item in schools or []: + item['id'] = item['idSchool'] + item['text'] = item['schoolName'] + return {'data': data} @endpoint( display_category='Inscriptions', diff --git a/tests/data/toulouse_maelis/R_get_child_subscribe_school_information.xml b/tests/data/toulouse_maelis/R_get_child_subscribe_school_information.xml index 97e68675..b8613fc9 100644 --- a/tests/data/toulouse_maelis/R_get_child_subscribe_school_information.xml +++ b/tests/data/toulouse_maelis/R_get_child_subscribe_school_information.xml @@ -35,6 +35,65 @@ 31400 + + 2022 + + CP + + + 2446 + FRANCE ANATOLE + + 2589 + FRANCE ANATOLE ELEMENTAIRE + 0561250508 +
+ 1502 + 21 + BD DE LA MEDITERRANEE + TOULOUSE + 31400 +
+ HOONHORST SEBASTIEN +
+
+ + 2578 + AMIDONNIERS ELEMENTAIRE + 05 34 24 58 95 +
+ 469 + 123 + ALL DE BRIENNE + TOULOUSE + 31000 +
+ TERRADA BENJAMIN +
+ + 2578 + AMIDONNIERS ELEMENTAIRE + 05 34 24 58 95 +
+ 469 + 123 + ALL DE BRIENNE + TOULOUSE + 31000 +
+ TERRADA BENJAMIN +
+ + 2654 + AUBRAC LUCIE ELEMENTAIRE + 05 61 13 99 38 +
+ + 38 +
+ WAIG FANG SANDRINE +
+
S10053183070 diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index 5deeef91..6288109a 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -4621,7 +4621,7 @@ def test_read_school_list_child_and_level(family_service, con, app): assert 'text' in item -def test_read_child_school_subscription_information(family_service, con, app): +def test_read_child_school_informations(family_service, con, app): family_service.add_soap_response( 'getChildSubscribeSchoolInformation', get_xml_file('R_get_child_subscribe_school_information.xml') ) @@ -4636,6 +4636,14 @@ def test_read_child_school_subscription_information(family_service, con, app): assert 'rl1Info' in resp.json['data'] assert 'childSubscribeSchoolInformation' in resp.json['data'] assert 'personSubscribeSchoolList' in resp.json['data'] + school_list = resp.json['data']['childSubscribeSchoolInformation']['subscribeSchoolInformation'][ + 'derogSchoolList' + ] + assert [(x['id'], x['text']) for x in school_list] == [ + ('2578', 'AMIDONNIERS ELEMENTAIRE'), + ('2578', 'AMIDONNIERS ELEMENTAIRE'), + ('2654', 'AUBRAC LUCIE ELEMENTAIRE'), + ] def test_create_child_school_pre_registration(family_service, con, app):