From 75e17ba29a3e915b298ee657ad38127ef40b4eae Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:05:53 +0200 Subject: [PATCH 1/8] toulouse-maelis: [tests] add 3 countries (#76608) --- tests/data/toulouse_maelis/R_read_country_list.xml | 12 ++++++++++++ tests/test_toulouse_maelis.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/data/toulouse_maelis/R_read_country_list.xml b/tests/data/toulouse_maelis/R_read_country_list.xml index 6afd3fb7..287c518f 100644 --- a/tests/data/toulouse_maelis/R_read_country_list.xml +++ b/tests/data/toulouse_maelis/R_read_country_list.xml @@ -25,6 +25,18 @@ 125 ALBANIE + + 99100 + FRANCE + + + 99350 + MAROC + + + 99351 + TUNISIE + diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index a88aa0fa..1c6590f6 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -656,8 +656,8 @@ def test_read_country_list(con, app): url = get_endpoint('read-country-list') resp = app.get(url) assert resp.json['err'] == 0 - assert len(resp.json['data']) == 3 - assert resp.json['data'] == [ + assert len(resp.json['data']) == 6 + assert resp.json['data'][:3] == [ {'id': '212', 'code': '212', 'text': 'AFGHANISTAN', 'libelle': 'AFGHANISTAN'}, {'id': '303', 'code': '303', 'text': 'AFRIQUE DU SUD', 'libelle': 'AFRIQUE DU SUD'}, {'id': '125', 'code': '125', 'text': 'ALBANIE', 'libelle': 'ALBANIE'}, -- 2.39.2 From ba7cf207b7b07c4700a60d1047c2d477cc0329fd Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:09:21 +0200 Subject: [PATCH 2/8] toulouse-maelsi: [tests] add a town (#76608) --- tests/data/toulouse_maelis/R_read_town_list.xml | 4 ++++ tests/test_toulouse_maelis.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/data/toulouse_maelis/R_read_town_list.xml b/tests/data/toulouse_maelis/R_read_town_list.xml index 188492b5..b11a10aa 100644 --- a/tests/data/toulouse_maelis/R_read_town_list.xml +++ b/tests/data/toulouse_maelis/R_read_town_list.xml @@ -13,6 +13,10 @@ 64001 AAST + + 91122 + BURES-SUR-YVETTE + diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index 1c6590f6..70d58790 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -668,9 +668,10 @@ def test_read_town_list(con, app): url = get_endpoint('read-town-list') resp = app.get(url) assert resp.json['err'] == 0 - assert len(resp.json['data']) == 3 + assert len(resp.json['data']) == 4 assert resp.json['data'] == [ {'code': '64001', 'id': '64001', 'libelle': 'AAST', 'text': 'AAST'}, + {'code': '91122', 'id': '91122', 'libelle': 'BURES-SUR-YVETTE', 'text': 'BURES-SUR-YVETTE'}, {'code': '07120', 'id': '07120', 'libelle': 'LACHAMP-RAPHAEL', 'text': 'LACHAMP-RAPHAEL'}, { 'code': '69391', @@ -689,6 +690,7 @@ def test_read_town_list(con, app): resp = app.get(url) assert resp.json['data'] == [ {'code': '64001', 'id': '64001', 'libelle': 'AAST', 'text': 'AAST'}, + {'code': '91122', 'id': '91122', 'libelle': 'BURES-SUR-YVETTE', 'text': 'BURES-SUR-YVETTE'}, { 'code': '07120', 'id': '07120', -- 2.39.2 From 80100d9d585694a335fd2e9276d8444af7e06fc7 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 09:02:17 +0200 Subject: [PATCH 3/8] toulouse-maelis: remove duplicated child birth definition (#76608) --- passerelle/contrib/toulouse_maelis/family_schemas.py | 1 - 1 file changed, 1 deletion(-) diff --git a/passerelle/contrib/toulouse_maelis/family_schemas.py b/passerelle/contrib/toulouse_maelis/family_schemas.py index 5ce3c379..6c7e78d8 100644 --- a/passerelle/contrib/toulouse_maelis/family_schemas.py +++ b/passerelle/contrib/toulouse_maelis/family_schemas.py @@ -554,7 +554,6 @@ CHILD_SCHEMA = { 'type': 'string', 'pattern': '.+', }, - 'birth': BIRTH_SCHEMA, 'dietcode': { 'description': 'Code de régime alimentaire (depuis référentiel)', 'oneOf': [{'type': 'string'}, {'type': 'null'}], -- 2.39.2 From c9edd27570d42f21c510d4d0762711a1c99dd354 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:03:14 +0200 Subject: [PATCH 4/8] toulouse-maelis: add county (or department) referential (#76608) --- passerelle/contrib/toulouse_maelis/models.py | 16 ++++++++++++++ .../toulouse_maelis/R_read_county_list.xml | 22 +++++++++++++++++++ tests/test_toulouse_maelis.py | 14 ++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 tests/data/toulouse_maelis/R_read_county_list.xml diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index c9d00a08..723b677a 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -170,6 +170,7 @@ class ToulouseMaelis(BaseResource, HTTPResource): 'ChildIndicator', 'Civility', 'Country', + 'County', 'CSP', 'DietCode', 'Document', @@ -818,6 +819,21 @@ class ToulouseMaelis(BaseResource, HTTPResource): def read_country_list(self, request, id=None, q=None, limit=None, distinct=True): return {'data': self.get_referential('Country', id, q, limit, distinct)} + @endpoint( + display_category='Famille', + description='Lister les départements', + name='read-county-list', + perm='can_access', + parameters={ + 'id': {'description': 'Identifiant de l’enregistrement'}, + 'q': {'description': 'Recherche en texte intégral'}, + 'limit': {'description': 'Nombre maximal de résultats; doit être inférieur à 20.'}, + 'distinct': {'description': 'Ne pas inclure les valeurs dupliquées'}, + }, + ) + def read_county_list(self, request, id=None, q=None, limit=None, distinct=True): + return {'data': self.get_referential('County', id, q, limit, distinct)} + @endpoint( display_category='Famille', description='Lister les communes', diff --git a/tests/data/toulouse_maelis/R_read_county_list.xml b/tests/data/toulouse_maelis/R_read_county_list.xml new file mode 100644 index 00000000..71a809ca --- /dev/null +++ b/tests/data/toulouse_maelis/R_read_county_list.xml @@ -0,0 +1,22 @@ + + + + + 01 + AIN + + + 02 + AISNE + + + 03 + ALLIER + + + 91 + ESSONNE + + + + diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index 70d58790..3375e4d3 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -189,6 +189,7 @@ def django_db_setup(django_db_setup, django_db_blocker): ) soap_mock.add_soap_response('readCivilityList', get_xml_file('R_read_civility_list.xml')) soap_mock.add_soap_response('readCountryList', get_xml_file('R_read_country_list.xml')) + soap_mock.add_soap_response('readCountyList', get_xml_file('R_read_county_list.xml')) soap_mock.add_soap_response('readCSPList', get_xml_file('R_read_csp_list.xml')) soap_mock.add_soap_response('readDietCodeList', get_xml_file('R_read_dietcode_list.xml')) soap_mock.add_soap_response('readDocumentList', get_xml_file('R_read_document_list.xml')) @@ -506,6 +507,7 @@ def test_cron(db): 'Civility', 'Complement', 'Country', + 'County', 'DerogReason', 'DietCode', 'Direct', @@ -664,6 +666,18 @@ def test_read_country_list(con, app): ] +def test_read_county_list(con, app): + url = get_endpoint('read-county-list') + resp = app.get(url) + assert resp.json['err'] == 0 + assert len(resp.json['data']) == 4 + assert resp.json['data'][:3] == [ + {'id': '01', 'code': '01', 'text': 'AIN', 'libelle': 'AIN'}, + {'id': '02', 'code': '02', 'text': 'AISNE', 'libelle': 'AISNE'}, + {'id': '03', 'code': '03', 'text': 'ALLIER', 'libelle': 'ALLIER'}, + ] + + def test_read_town_list(con, app): url = get_endpoint('read-town-list') resp = app.get(url) -- 2.39.2 From 10224eebbfe6147d517e181778c4a8d31898a1cb Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:12:43 +0200 Subject: [PATCH 5/8] toulouse-maelis: manage birth department on payload (#76608) --- .../contrib/toulouse_maelis/family_schemas.py | 4 ++ passerelle/contrib/toulouse_maelis/models.py | 14 ++++++ tests/test_toulouse_maelis.py | 47 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/passerelle/contrib/toulouse_maelis/family_schemas.py b/passerelle/contrib/toulouse_maelis/family_schemas.py index 6c7e78d8..8766d540 100644 --- a/passerelle/contrib/toulouse_maelis/family_schemas.py +++ b/passerelle/contrib/toulouse_maelis/family_schemas.py @@ -132,6 +132,10 @@ BIRTH_SCHEMA = { 'description': 'Commune de naissance (depuis référentiel)', 'oneOf': [{'type': 'string'}, {'type': 'null'}], }, + 'cdDepartment': { + 'description': 'Département naissance (depuis référentiel)', + 'oneOf': [{'type': 'string'}, {'type': 'null'}], + }, 'countryCode': { 'description': 'Pays de naissance (depuis référentiel)', 'oneOf': [{'type': 'string'}, {'type': 'null'}], diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index 723b677a..4824e5bb 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -555,6 +555,18 @@ class ToulouseMaelis(BaseResource, HTTPResource): 'Vaccin', post_data, keys + ['vaccinList', i, 'code'], required=False ) + def check_and_adapt_birth_payload_in_referential(self, post_data, parent_keys=None): + keys = parent_keys or [] + self.assert_post_data_in_referential( + 'Town', post_data, keys + ['birth', 'communeCode'], required=False + ) + self.assert_post_data_in_referential( + 'County', post_data, keys + ['birth', 'cdDepartment'], required=False + ) + self.assert_post_data_in_referential( + 'Country', post_data, keys + ['birth', 'countryCode'], required=False + ) + def check_and_adapt_child_pai_payoad_in_referential(self, post_data, parent_keys=None): keys = parent_keys or [] self.assert_post_data_in_referential('PAI', post_data, keys + ['code']) @@ -588,6 +600,7 @@ class ToulouseMaelis(BaseResource, HTTPResource): post_data, keys + ['medicalRecord'] ) self.check_and_adapt_update_indicator_payload_in_referential('ChildIndicator', post_data, keys) + self.check_and_adapt_birth_payload_in_referential(post_data, keys) def check_and_adapt_person_payload_in_referential(self, post_data, parent_keys=None): keys = parent_keys or [] @@ -626,6 +639,7 @@ class ToulouseMaelis(BaseResource, HTTPResource): self.assert_post_data_in_referential('Quality', post_data, keys + ['quality']) self.check_and_adapt_update_coordinate_payload_in_referential(post_data, keys) self.check_and_adapt_update_indicator_payload_in_referential('RLIndicator', post_data, keys) + self.check_and_adapt_birth_payload_in_referential(post_data, keys) def check_and_adapt_create_rl1_payload_in_referential(self, post_data): self.assert_post_data_in_referential('Category', post_data, ['category']) diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index 3375e4d3..8c5d107a 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -2160,6 +2160,7 @@ def test_create_family(family_service, con, app): 'rl1/lastname': 'Doe', 'rl1/quality': 'AU', 'rl1/birth/communeCode': None, + 'rl1/birth/cdDepartment': '91', 'rl1/birth/countryCode': '99350', 'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/place': 'Rabbat', @@ -2183,6 +2184,7 @@ def test_create_family(family_service, con, app): 'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/place': 'Saint-louis', 'childList/0/birth/communeCode': '91122', + 'childList/0/birth/cdDepartment': '91', 'childList/0/birth/countryCode': '99100', 'childList/0/dietcode': 'RSV', 'childList/0/medicalRecord/vaccinList/0/code': 'DTC', @@ -2281,6 +2283,7 @@ def test_create_family_wrong_referential_key_error(con, app): 'rl1/lastname': 'Doe', 'rl1/quality': 'AU', 'rl1/birth/communeCode': None, + 'rl1/birth/cdDepartment': '91', 'rl1/birth/countryCode': '99350', 'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/place': 'Rabbat', @@ -2297,6 +2300,7 @@ def test_create_family_wrong_referential_key_error(con, app): 'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/place': 'Saint-louis', 'childList/0/birth/communeCode': '91122', + 'childList/0/birth/cdDepartment': '91', 'childList/0/birth/countryCode': '99100', 'childList/0/dietcode': 'RSV', 'childList/0/medicalRecord/vaccinList/0/code': 'plop', @@ -2319,6 +2323,15 @@ def test_create_family_wrong_referential_key_error(con, app): == "rl1/profession/situation key value 'plop' do not belong to 'ProfessionalSituation' referential" ) + params['rl1/profession/situation'] = '01' + params['childList/0/birth/cdDepartment'] = 'plop' + resp = app.post_json(url + '?NameID=local', params=params) + assert resp.json['err'] == 1 + assert ( + resp.json['err_desc'] + == "childList/0/birth/cdDepartment key value 'plop' do not belong to 'County' referential" + ) + def test_update_family(family_service, con, app): def request_check(request): @@ -2336,6 +2349,7 @@ def test_update_family(family_service, con, app): 'rl1/lastname': 'Doe', 'rl1/quality': 'AU', 'rl1/birth/communeCode': None, + 'rl1/birth/cdDepartment': '91', 'rl1/birth/countryCode': '99350', 'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/place': 'Rabbat', @@ -2357,6 +2371,9 @@ def test_update_family(family_service, con, app): 'childList/0/sexe': 'M', 'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/place': 'Duluth', + 'childList/0/birth/communeCode': '91122', + 'childList/0/birth/cdDepartment': '91', + 'childList/0/birth/countryCode': '99100', 'childList/0/dietcode': 'RSV', 'childList/0/paiInfoBean/code': 'PAIALI', 'childList/0/medicalRecord/vaccinList/0/code': 'DTC', @@ -2457,6 +2474,7 @@ def test_update_family_wrong_referential_key_error(con, app): 'rl1/lastname': 'Doe', 'rl1/quality': 'AU', 'rl1/birth/communeCode': None, + 'rl1/birth/cdDepartment': '91', 'rl1/birth/countryCode': '99350', 'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/place': 'Rabbat', @@ -2478,6 +2496,9 @@ def test_update_family_wrong_referential_key_error(con, app): 'childList/0/sexe': 'M', 'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/place': 'Duluth', + 'childList/0/birth/communeCode': '91122', + 'childList/0/birth/cdDepartment': '91', + 'childList/0/birth/countryCode': '99100', 'childList/0/dietcode': 'RSV', 'childList/0/paiInfoBean/code': 'PAIALI', 'childList/0/medicalRecord/vaccinList/0/code': 'plop', @@ -2501,6 +2522,15 @@ def test_update_family_wrong_referential_key_error(con, app): == "rl1/profession/situation key value 'plop' do not belong to 'ProfessionalSituation' referential" ) + params['rl1/profession/situation'] = '01' + params['childList/0/birth/communeCode'] = 'plop' + resp = app.post_json(url + '?NameID=local', params=params) + assert resp.json['err'] == 1 + assert ( + resp.json['err_desc'] + == "childList/0/birth/communeCode key value 'plop' do not belong to 'Town' referential" + ) + def test_create_rl1(family_service, con, app): family_service.add_soap_response('createFamily', get_xml_file('R_create_family.xml')) @@ -2592,6 +2622,15 @@ def test_create_rl1_wrong_referential_key_error(con, app): == "rl1/adresse/numComp key value 'plop' do not belong to 'Complement' referential" ) + params['rl1/adresse/numComp'] = 'B' + params['rl1/birth/countryCode'] = 'plop' + resp = app.post_json(url + '?NameID=local', params=params) + assert resp.json['err'] == 1 + assert ( + resp.json['err_desc'] + == "rl1/birth/countryCode key value 'plop' do not belong to 'Country' referential" + ) + def test_create_rl1_maelis_error(family_service, con, app): family_service.add_soap_response('createFamily', get_xml_file('R_create_family_error.xml')) @@ -2973,6 +3012,14 @@ def test_create_child_wrong_referential_key_error(con, app): assert resp.json['err'] == 1 assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential" + params['sexe'] = 'F' + params['birth/cdDepartment'] = 'plop' + resp = app.post_json(url + '?NameID=local', params=params) + assert resp.json['err'] == 1 + assert ( + resp.json['err_desc'] == "birth/cdDepartment key value 'plop' do not belong to 'County' referential" + ) + def test_create_child_connection_error(family_service, con, app): family_service.add_soap_response('createChild', ConnectionError('No address associated with hostname')) -- 2.39.2 From 56d14bd44056e87b63f024bba6ef73b48cb93990 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:16:11 +0200 Subject: [PATCH 6/8] toulouse-maelis: read family adding birth referentials text values (#76608) --- passerelle/contrib/toulouse_maelis/models.py | 7 +++++++ tests/data/toulouse_maelis/R_read_family.xml | 3 +++ .../data/toulouse_maelis/R_read_family_relax.xml | 3 +++ .../toulouse_maelis/R_read_family_reordered.xml | 3 +++ tests/test_toulouse_maelis.py | 15 ++++++++++++--- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index 4824e5bb..14614d5a 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -409,6 +409,11 @@ class ToulouseMaelis(BaseResource, HTTPResource): subscribe_natures[school_year].add(activity_nature['code']) data['subscribe_natures'] = {x: sorted(list(y)) for x, y in subscribe_natures.items()} + def add_text_value_to_birth(self, data): + self.add_text_value('Town', data, ['birth', 'communeCode']) + self.add_text_value('County', data, ['birth', 'cdDepartment']) + self.add_text_value('Country', data, ['birth', 'countryCode']) + def add_text_value_to_rl_indicator(self, data): self.add_text_value('RLIndicator', data, ['code']) @@ -434,6 +439,7 @@ class ToulouseMaelis(BaseResource, HTTPResource): city = CityModel.objects.filter(code=data['birth']['communeCode']).first() if city: data['birth']['zipCode'] = city.zipcode + self.add_text_value_to_birth(data) def add_text_value_to_person(self, data): self.add_text_value('Civility', data, ['civility']) @@ -458,6 +464,7 @@ class ToulouseMaelis(BaseResource, HTTPResource): city = CityModel.objects.filter(code=data['birth']['communeCode']).first() if city: data['birth']['zipCode'] = city.zipcode + self.add_text_value_to_birth(data) def add_text_value_to_family(self, data): self.add_text_value('Category', data, ['category']) diff --git a/tests/data/toulouse_maelis/R_read_family.xml b/tests/data/toulouse_maelis/R_read_family.xml index 8eda08ea..53b7d284 100644 --- a/tests/data/toulouse_maelis/R_read_family.xml +++ b/tests/data/toulouse_maelis/R_read_family.xml @@ -17,6 +17,7 @@ 1938-07-26T00:00:00+01:00 Rabbat 91122 + 91 99350 @@ -72,6 +73,7 @@ 1940-06-22T00:00:00+02:00 Bardot 91122 + 91 99351 @@ -140,6 +142,7 @@ 1943-01-19T00:00:00+01:00 Saint-louis 91122 + 91 99100 RSV diff --git a/tests/data/toulouse_maelis/R_read_family_relax.xml b/tests/data/toulouse_maelis/R_read_family_relax.xml index 48074f55..4098b4ce 100644 --- a/tests/data/toulouse_maelis/R_read_family_relax.xml +++ b/tests/data/toulouse_maelis/R_read_family_relax.xml @@ -17,6 +17,7 @@ 1938-07-26T00:00:00+01:00 Rabbat 91122 + 91 99350 @@ -72,6 +73,7 @@ 1940-06-22T00:00:00+02:00 Bardot 91122 + 91 99351 @@ -140,6 +142,7 @@ 1943-01-19T00:00:00+01:00 Saint-louis 91122 + 91 99100 RSV diff --git a/tests/data/toulouse_maelis/R_read_family_reordered.xml b/tests/data/toulouse_maelis/R_read_family_reordered.xml index 89dec11b..38864ff1 100644 --- a/tests/data/toulouse_maelis/R_read_family_reordered.xml +++ b/tests/data/toulouse_maelis/R_read_family_reordered.xml @@ -17,6 +17,7 @@ 1938-07-26T00:00:00+01:00 Rabbat 91122 + 91 99350 @@ -72,6 +73,7 @@ 1940-06-22T00:00:00+02:00 Bardot 91122 + 91 99351 @@ -140,6 +142,7 @@ 1943-01-19T00:00:00+01:00 Saint-louis 91122 + 91 99100 RSV diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index 8c5d107a..bc682268 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -1394,11 +1394,14 @@ def test_read_family(family_service, xml, con, app): 'quality': 'PERE', 'civility': 'M.', 'birth': { - 'cdDepartment': None, + 'cdDepartment': '91', 'communeCode': '91122', 'countryCode': '99350', 'dateBirth': '1938-07-26T00:00:00+01:00', 'place': 'Rabbat', + 'cdDepartment_text': 'ESSONNE', + 'communeCode_text': 'BURES-SUR-YVETTE', + 'countryCode_text': 'MAROC', }, 'adresse': { 'idStreet': 'AM0330', @@ -1510,11 +1513,14 @@ def test_read_family(family_service, xml, con, app): 'sexe': 'F', 'sexe_text': 'Féminin', 'birth': { - 'cdDepartment': None, + 'cdDepartment': '91', 'dateBirth': '1943-01-19T00:00:00+01:00', 'place': 'Saint-louis', 'communeCode': '91122', 'countryCode': '99100', + 'cdDepartment_text': 'ESSONNE', + 'communeCode_text': 'BURES-SUR-YVETTE', + 'countryCode_text': 'FRANCE', }, 'dietcode': 'RSV', 'dietcode_text': '3- RÉGIME SANS VIANDE', @@ -1760,11 +1766,14 @@ def test_read_rl2(family_service, con, app): 'quality': 'MERE', 'civility': 'MME', 'birth': { - 'cdDepartment': None, + 'cdDepartment': '91', 'communeCode': '91122', 'countryCode': '99351', 'dateBirth': '1940-06-22T00:00:00+02:00', 'place': 'Bardot', + 'cdDepartment_text': 'ESSONNE', + 'communeCode_text': 'BURES-SUR-YVETTE', + 'countryCode_text': 'TUNISIE', }, 'adresse': { 'idStreet': None, -- 2.39.2 From f8124d9ece60342bb9151f4fadb062df5f216856 Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:23:47 +0200 Subject: [PATCH 7/8] toulouse-maelis: factorize adding birth zipcode (#76608) --- passerelle/contrib/toulouse_maelis/models.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index 14614d5a..e3dfa280 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -413,6 +413,10 @@ class ToulouseMaelis(BaseResource, HTTPResource): self.add_text_value('Town', data, ['birth', 'communeCode']) self.add_text_value('County', data, ['birth', 'cdDepartment']) self.add_text_value('Country', data, ['birth', 'countryCode']) + if data['birth'].get('communeCode'): + city = CityModel.objects.filter(code=data['birth']['communeCode']).first() + if city: + data['birth']['zipCode'] = city.zipcode def add_text_value_to_rl_indicator(self, data): self.add_text_value('RLIndicator', data, ['code']) @@ -435,10 +439,6 @@ class ToulouseMaelis(BaseResource, HTTPResource): self.add_text_value_to_child_indicator(indicator) self.add_indicators_field('ChildIndicator', data) self.add_nature_subscriptions(data) - if data.get('birth') and data['birth'].get('communeCode'): - city = CityModel.objects.filter(code=data['birth']['communeCode']).first() - if city: - data['birth']['zipCode'] = city.zipcode self.add_text_value_to_birth(data) def add_text_value_to_person(self, data): @@ -460,10 +460,6 @@ class ToulouseMaelis(BaseResource, HTTPResource): self.add_text_value('Quotient', quotient, ['cdquo']) self.add_indicators_field('RLIndicator', data) self.add_nature_subscriptions(data) - if data.get('birth') and data['birth'].get('communeCode'): - city = CityModel.objects.filter(code=data['birth']['communeCode']).first() - if city: - data['birth']['zipCode'] = city.zipcode self.add_text_value_to_birth(data) def add_text_value_to_family(self, data): -- 2.39.2 From e852d7e2f360ff9c750defd0bd0e075a72289aeb Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Sat, 15 Apr 2023 12:17:07 +0200 Subject: [PATCH 8/8] toujouse-maelis: [functests] add birth informations (#76608) --- functests/toulouse_maelis/conftest.py | 21 ++++++++++++++++--- .../data/test_create_family.json | 13 +++++++----- .../toulouse_maelis/data/test_create_rl2.json | 8 ++++--- .../data/test_update_child.json | 5 +++-- .../data/test_update_family.json | 21 ++++++++++++------- .../data/test_update_family_ras.json | 10 +++++---- .../toulouse_maelis/data/test_update_rl2.json | 5 +++-- functests/toulouse_maelis/test_00_data.py | 3 ++- functests/toulouse_maelis/test_02_family.py | 21 ++++++++++++++++--- functests/toulouse_maelis/test_04_loisirs.py | 7 +++++-- 10 files changed, 81 insertions(+), 33 deletions(-) diff --git a/functests/toulouse_maelis/conftest.py b/functests/toulouse_maelis/conftest.py index 24008303..c86db293 100644 --- a/functests/toulouse_maelis/conftest.py +++ b/functests/toulouse_maelis/conftest.py @@ -24,7 +24,10 @@ FAMILY_PAYLOAD = { 'lastname': 'Simpson', 'maidenName': 'Bouvier', 'quality': 'MERE', - 'birth': {'dateBirth': '1950-10-01'}, + 'birth': { + 'dateBirth': '1950-10-01', + 'countryCode': '404', + }, 'adresse': { 'idStreet': '2317', 'num': '4', @@ -38,7 +41,13 @@ FAMILY_PAYLOAD = { 'firstname': 'Homer', 'lastname': 'Simpson', 'quality': 'PERE', - 'birth': {'dateBirth': '1956-05-12'}, + 'birth': { + 'dateBirth': '1956-05-12', + 'place': 'Brive-la-Gaillarde', + 'communeCode': '19031', + 'cdDepartment': '19', + 'countryCode': '', + }, 'adresse': { 'num': '742', 'numComp': None, @@ -88,7 +97,13 @@ FAMILY_PAYLOAD = { 'sexe': 'M', 'firstname': 'Bart', 'lastname': 'Simpson', - 'birth': {'dateBirth': '2014-04-01'}, + 'birth': { + 'dateBirth': '2014-04-01', + 'place': 'Brive-la-Gaillarde', + 'communeCode': '19031', + 'cdDepartment': '19', + 'countryCode': '', + }, 'bPhoto': True, 'bLeaveAlone': True, 'dietcode': 'MENU_AV', diff --git a/functests/toulouse_maelis/data/test_create_family.json b/functests/toulouse_maelis/data/test_create_family.json index 46cef3ce..8f447a31 100644 --- a/functests/toulouse_maelis/data/test_create_family.json +++ b/functests/toulouse_maelis/data/test_create_family.json @@ -17,8 +17,9 @@ "dateBirth": "1950-10-01T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "adresse": { "idStreet": "2317", @@ -56,10 +57,12 @@ "sexe": "M", "birth": { "dateBirth": "2014-04-01T00:00:00+02:00", - "place": null, - "communeCode": null, + "place": "Brive-la-Gaillarde", + "communeCode": "19031", "countryCode": null, - "cdDepartment": null + "cdDepartment": "19", + "communeCode_text": "BRIVE-LA-GAILLARDE", + "cdDepartment_text": "CORREZE" }, "dietcode": "MENU_AV", "bPhoto": true, diff --git a/functests/toulouse_maelis/data/test_create_rl2.json b/functests/toulouse_maelis/data/test_create_rl2.json index 938f6940..e7f8b5f6 100644 --- a/functests/toulouse_maelis/data/test_create_rl2.json +++ b/functests/toulouse_maelis/data/test_create_rl2.json @@ -7,10 +7,12 @@ "civility": "MR", "birth": { "dateBirth": "1956-05-12T00:00:00+01:00", - "place": null, - "communeCode": null, + "place": "Brive-la-Gaillarde", + "communeCode": "19031", "countryCode": null, - "cdDepartment": null + "cdDepartment": "19", + "communeCode_text": "BRIVE-LA-GAILLARDE", + "cdDepartment_text": "CORREZE" }, "adresse": { "idStreet": null, diff --git a/functests/toulouse_maelis/data/test_update_child.json b/functests/toulouse_maelis/data/test_update_child.json index d4a61fac..91d4cab6 100644 --- a/functests/toulouse_maelis/data/test_update_child.json +++ b/functests/toulouse_maelis/data/test_update_child.json @@ -7,8 +7,9 @@ "dateBirth": "1970-01-01T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "dietcode": "MENU_AV", "bPhoto": false, diff --git a/functests/toulouse_maelis/data/test_update_family.json b/functests/toulouse_maelis/data/test_update_family.json index 89ac6bcf..f949254c 100644 --- a/functests/toulouse_maelis/data/test_update_family.json +++ b/functests/toulouse_maelis/data/test_update_family.json @@ -17,8 +17,9 @@ "dateBirth": "1950-10-01T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "adresse": { "idStreet": "2317", @@ -55,10 +56,12 @@ "civility": "MR", "birth": { "dateBirth": "1956-05-12T00:00:00+01:00", - "place": null, - "communeCode": null, + "place": "Brive-la-Gaillarde", + "communeCode": "19031", "countryCode": null, - "cdDepartment": null + "cdDepartment": "19", + "communeCode_text": "BRIVE-LA-GAILLARDE", + "cdDepartment_text": "CORREZE" }, "adresse": { "idStreet": null, @@ -127,10 +130,12 @@ "sexe": "M", "birth": { "dateBirth": "2014-04-01T00:00:00+02:00", - "place": null, - "communeCode": null, + "place": "Brive-la-Gaillarde", + "communeCode": "19031", "countryCode": null, - "cdDepartment": null + "cdDepartment": "19", + "communeCode_text": "BRIVE-LA-GAILLARDE", + "cdDepartment_text": "CORREZE" }, "dietcode": "MENU_AV", "bPhoto": true, diff --git a/functests/toulouse_maelis/data/test_update_family_ras.json b/functests/toulouse_maelis/data/test_update_family_ras.json index 8765452b..cfebfcf7 100644 --- a/functests/toulouse_maelis/data/test_update_family_ras.json +++ b/functests/toulouse_maelis/data/test_update_family_ras.json @@ -56,8 +56,9 @@ "dateBirth": "1956-05-12T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "adresse": { "idStreet": null, @@ -113,8 +114,9 @@ "dateBirth": "1970-01-01T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "dietcode": null, "bPhoto": false, diff --git a/functests/toulouse_maelis/data/test_update_rl2.json b/functests/toulouse_maelis/data/test_update_rl2.json index 8d457349..dad93980 100644 --- a/functests/toulouse_maelis/data/test_update_rl2.json +++ b/functests/toulouse_maelis/data/test_update_rl2.json @@ -9,8 +9,9 @@ "dateBirth": "1956-05-12T00:00:00+01:00", "place": null, "communeCode": null, - "countryCode": null, - "cdDepartment": null + "countryCode": "404", + "cdDepartment": null, + "countryCode_text": "USA" }, "adresse": { "idStreet": null, diff --git a/functests/toulouse_maelis/test_00_data.py b/functests/toulouse_maelis/test_00_data.py index 87d80577..9a836563 100644 --- a/functests/toulouse_maelis/test_00_data.py +++ b/functests/toulouse_maelis/test_00_data.py @@ -11,6 +11,7 @@ from .conftest import diff 'child-indicator', 'civility', 'country', + 'county', 'csp', 'dietcode', 'document', @@ -34,5 +35,5 @@ def test_referentials(conn, referentials, ref): for item in res['data']: assert 'id' in item assert 'text' in item - if ref not in ['street']: + if ref not in ['street', 'county']: assert diff(res['data'], 'test_read_%s_list.json' % ref) diff --git a/functests/toulouse_maelis/test_02_family.py b/functests/toulouse_maelis/test_02_family.py index a7083976..58559960 100644 --- a/functests/toulouse_maelis/test_02_family.py +++ b/functests/toulouse_maelis/test_02_family.py @@ -18,7 +18,10 @@ FAMILY_RESET_PAYLOAD = { 'lastname': 'Simpson', # must be 'maidenName': 'reset', # no effect 'quality': 'AU', - 'birth': {'dateBirth': '1950-10-01'}, # must be + 'birth': { + 'dateBirth': '1950-10-01', # must be + 'countryCode': '', + }, 'adresse': {'idStreet': '', 'street1': 'reset', 'town': 'reset', 'zipcode': 'reset'}, }, 'rl2': { @@ -26,7 +29,13 @@ FAMILY_RESET_PAYLOAD = { 'firstname': 'Homer', # must be 'lastname': 'Simpson', # must be 'quality': 'AU', - 'birth': {'dateBirth': '1956-05-12'}, # must be + 'birth': { + 'dateBirth': '1956-05-12', # must be + 'place': '', + 'communeCode': '', + 'cdDepartment': '', + 'countryCode': '404', + }, 'adresse': { 'num': '42', 'numComp': 'Q', @@ -71,7 +80,13 @@ FAMILY_RESET_PAYLOAD = { 'sexe': 'F', 'firstname': 'Bartolome', # some side effects, cf test_update_child 'lastname': 'Simps', - 'birth': {'dateBirth': '1970-01-01'}, + 'birth': { + 'dateBirth': '1970-01-01', + 'place': '', + 'communeCode': '', + 'cdDepartment': '', + 'countryCode': '404', + }, 'bPhoto': False, 'bLeaveAlone': False, 'dietcode': '', diff --git a/functests/toulouse_maelis/test_04_loisirs.py b/functests/toulouse_maelis/test_04_loisirs.py index 80e34f22..47acfe73 100644 --- a/functests/toulouse_maelis/test_04_loisirs.py +++ b/functests/toulouse_maelis/test_04_loisirs.py @@ -17,5 +17,8 @@ def test_catalog_general_loisirs(conn, update_data): resp.raise_for_status() assert resp.json()['err'] == 0 - # still not nature code defined on LOISIR activities - assert len(resp.json()['data']) == 0 + [x['text'] for x in resp.json()['data']] == [ + 'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES, MERCREDI - 13h45/17h - 8/15Ans, ARGOULETS', + 'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES, MERCREDI - 14h/16h30 - 10/15Ans, LA RAMEE', + 'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES, MERCREDI - 15h30/17h - 8/15Ans, ARGOULETS', + ] -- 2.39.2