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', + ] diff --git a/passerelle/contrib/toulouse_maelis/family_schemas.py b/passerelle/contrib/toulouse_maelis/family_schemas.py index 5ce3c379..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'}], @@ -554,7 +558,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'}], diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index c9d00a08..e3dfa280 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', @@ -408,6 +409,15 @@ 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']) + 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']) @@ -429,10 +439,7 @@ 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): self.add_text_value('Civility', data, ['civility']) @@ -453,10 +460,7 @@ 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): self.add_text_value('Category', data, ['category']) @@ -554,6 +558,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']) @@ -587,6 +603,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 [] @@ -625,6 +642,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']) @@ -818,6 +836,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_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/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/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/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 a88aa0fa..bc682268 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', @@ -656,21 +658,34 @@ 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'}, ] +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) 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 +704,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', @@ -1378,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', @@ -1494,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', @@ -1744,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, @@ -2144,6 +2169,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', @@ -2167,6 +2193,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', @@ -2265,6 +2292,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', @@ -2281,6 +2309,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', @@ -2303,6 +2332,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): @@ -2320,6 +2358,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', @@ -2341,6 +2380,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', @@ -2441,6 +2483,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', @@ -2462,6 +2505,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', @@ -2485,6 +2531,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')) @@ -2576,6 +2631,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')) @@ -2957,6 +3021,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'))