toulouse-maelis: ajouter le département aux informations de naissances #209

Merged
nroche merged 8 commits from wip/76608-parsifal-birth-county into main 2023-04-17 17:28:51 +02:00
19 changed files with 251 additions and 48 deletions

View File

@ -24,7 +24,10 @@ FAMILY_PAYLOAD = {
'lastname': 'Simpson', 'lastname': 'Simpson',
'maidenName': 'Bouvier', 'maidenName': 'Bouvier',
'quality': 'MERE', 'quality': 'MERE',
'birth': {'dateBirth': '1950-10-01'}, 'birth': {
'dateBirth': '1950-10-01',
'countryCode': '404',
},
'adresse': { 'adresse': {
'idStreet': '2317', 'idStreet': '2317',
'num': '4', 'num': '4',
@ -38,7 +41,13 @@ FAMILY_PAYLOAD = {
'firstname': 'Homer', 'firstname': 'Homer',
'lastname': 'Simpson', 'lastname': 'Simpson',
'quality': 'PERE', 'quality': 'PERE',
'birth': {'dateBirth': '1956-05-12'}, 'birth': {
'dateBirth': '1956-05-12',
'place': 'Brive-la-Gaillarde',
'communeCode': '19031',
'cdDepartment': '19',
'countryCode': '',
},
'adresse': { 'adresse': {
'num': '742', 'num': '742',
'numComp': None, 'numComp': None,
@ -88,7 +97,13 @@ FAMILY_PAYLOAD = {
'sexe': 'M', 'sexe': 'M',
'firstname': 'Bart', 'firstname': 'Bart',
'lastname': 'Simpson', 'lastname': 'Simpson',
'birth': {'dateBirth': '2014-04-01'}, 'birth': {
'dateBirth': '2014-04-01',
'place': 'Brive-la-Gaillarde',
'communeCode': '19031',
'cdDepartment': '19',
'countryCode': '',
},
'bPhoto': True, 'bPhoto': True,
'bLeaveAlone': True, 'bLeaveAlone': True,
'dietcode': 'MENU_AV', 'dietcode': 'MENU_AV',

View File

@ -17,8 +17,9 @@
"dateBirth": "1950-10-01T00:00:00+01:00", "dateBirth": "1950-10-01T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"adresse": { "adresse": {
"idStreet": "2317", "idStreet": "2317",
@ -56,10 +57,12 @@
"sexe": "M", "sexe": "M",
"birth": { "birth": {
"dateBirth": "2014-04-01T00:00:00+02:00", "dateBirth": "2014-04-01T00:00:00+02:00",
"place": null, "place": "Brive-la-Gaillarde",
"communeCode": null, "communeCode": "19031",
"countryCode": null, "countryCode": null,
"cdDepartment": null "cdDepartment": "19",
"communeCode_text": "BRIVE-LA-GAILLARDE",
"cdDepartment_text": "CORREZE"
}, },
"dietcode": "MENU_AV", "dietcode": "MENU_AV",
"bPhoto": true, "bPhoto": true,

View File

@ -7,10 +7,12 @@
"civility": "MR", "civility": "MR",
"birth": { "birth": {
"dateBirth": "1956-05-12T00:00:00+01:00", "dateBirth": "1956-05-12T00:00:00+01:00",
"place": null, "place": "Brive-la-Gaillarde",
"communeCode": null, "communeCode": "19031",
"countryCode": null, "countryCode": null,
"cdDepartment": null "cdDepartment": "19",
"communeCode_text": "BRIVE-LA-GAILLARDE",
"cdDepartment_text": "CORREZE"
}, },
"adresse": { "adresse": {
"idStreet": null, "idStreet": null,

View File

@ -7,8 +7,9 @@
"dateBirth": "1970-01-01T00:00:00+01:00", "dateBirth": "1970-01-01T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"dietcode": "MENU_AV", "dietcode": "MENU_AV",
"bPhoto": false, "bPhoto": false,

View File

@ -17,8 +17,9 @@
"dateBirth": "1950-10-01T00:00:00+01:00", "dateBirth": "1950-10-01T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"adresse": { "adresse": {
"idStreet": "2317", "idStreet": "2317",
@ -55,10 +56,12 @@
"civility": "MR", "civility": "MR",
"birth": { "birth": {
"dateBirth": "1956-05-12T00:00:00+01:00", "dateBirth": "1956-05-12T00:00:00+01:00",
"place": null, "place": "Brive-la-Gaillarde",
"communeCode": null, "communeCode": "19031",
"countryCode": null, "countryCode": null,
"cdDepartment": null "cdDepartment": "19",
"communeCode_text": "BRIVE-LA-GAILLARDE",
"cdDepartment_text": "CORREZE"
}, },
"adresse": { "adresse": {
"idStreet": null, "idStreet": null,
@ -127,10 +130,12 @@
"sexe": "M", "sexe": "M",
"birth": { "birth": {
"dateBirth": "2014-04-01T00:00:00+02:00", "dateBirth": "2014-04-01T00:00:00+02:00",
"place": null, "place": "Brive-la-Gaillarde",
"communeCode": null, "communeCode": "19031",
"countryCode": null, "countryCode": null,
"cdDepartment": null "cdDepartment": "19",
"communeCode_text": "BRIVE-LA-GAILLARDE",
"cdDepartment_text": "CORREZE"
}, },
"dietcode": "MENU_AV", "dietcode": "MENU_AV",
"bPhoto": true, "bPhoto": true,

View File

@ -56,8 +56,9 @@
"dateBirth": "1956-05-12T00:00:00+01:00", "dateBirth": "1956-05-12T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"adresse": { "adresse": {
"idStreet": null, "idStreet": null,
@ -113,8 +114,9 @@
"dateBirth": "1970-01-01T00:00:00+01:00", "dateBirth": "1970-01-01T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"dietcode": null, "dietcode": null,
"bPhoto": false, "bPhoto": false,

View File

@ -9,8 +9,9 @@
"dateBirth": "1956-05-12T00:00:00+01:00", "dateBirth": "1956-05-12T00:00:00+01:00",
"place": null, "place": null,
"communeCode": null, "communeCode": null,
"countryCode": null, "countryCode": "404",
"cdDepartment": null "cdDepartment": null,
"countryCode_text": "USA"
}, },
"adresse": { "adresse": {
"idStreet": null, "idStreet": null,

View File

@ -11,6 +11,7 @@ from .conftest import diff
'child-indicator', 'child-indicator',
'civility', 'civility',
'country', 'country',
'county',
'csp', 'csp',
'dietcode', 'dietcode',
'document', 'document',
@ -34,5 +35,5 @@ def test_referentials(conn, referentials, ref):
for item in res['data']: for item in res['data']:
assert 'id' in item assert 'id' in item
assert 'text' 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) assert diff(res['data'], 'test_read_%s_list.json' % ref)

View File

@ -18,7 +18,10 @@ FAMILY_RESET_PAYLOAD = {
'lastname': 'Simpson', # must be 'lastname': 'Simpson', # must be
'maidenName': 'reset', # no effect 'maidenName': 'reset', # no effect
'quality': 'AU', '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'}, 'adresse': {'idStreet': '', 'street1': 'reset', 'town': 'reset', 'zipcode': 'reset'},
}, },
'rl2': { 'rl2': {
@ -26,7 +29,13 @@ FAMILY_RESET_PAYLOAD = {
'firstname': 'Homer', # must be 'firstname': 'Homer', # must be
'lastname': 'Simpson', # must be 'lastname': 'Simpson', # must be
'quality': 'AU', 'quality': 'AU',
'birth': {'dateBirth': '1956-05-12'}, # must be 'birth': {
'dateBirth': '1956-05-12', # must be
'place': '',
'communeCode': '',
'cdDepartment': '',
'countryCode': '404',
},
'adresse': { 'adresse': {
'num': '42', 'num': '42',
'numComp': 'Q', 'numComp': 'Q',
@ -71,7 +80,13 @@ FAMILY_RESET_PAYLOAD = {
'sexe': 'F', 'sexe': 'F',
'firstname': 'Bartolome', # some side effects, cf test_update_child 'firstname': 'Bartolome', # some side effects, cf test_update_child
'lastname': 'Simps', 'lastname': 'Simps',
'birth': {'dateBirth': '1970-01-01'}, 'birth': {
'dateBirth': '1970-01-01',
'place': '',
'communeCode': '',
'cdDepartment': '',
'countryCode': '404',
},
'bPhoto': False, 'bPhoto': False,
'bLeaveAlone': False, 'bLeaveAlone': False,
'dietcode': '', 'dietcode': '',

View File

@ -17,5 +17,8 @@ def test_catalog_general_loisirs(conn, update_data):
resp.raise_for_status() resp.raise_for_status()
assert resp.json()['err'] == 0 assert resp.json()['err'] == 0
# still not nature code defined on LOISIR activities [x['text'] for x in resp.json()['data']] == [
assert len(resp.json()['data']) == 0 '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',
]

View File

@ -132,6 +132,10 @@ BIRTH_SCHEMA = {
'description': 'Commune de naissance (depuis référentiel)', 'description': 'Commune de naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}], 'oneOf': [{'type': 'string'}, {'type': 'null'}],
}, },
'cdDepartment': {
'description': 'Département naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}],
},
'countryCode': { 'countryCode': {
'description': 'Pays de naissance (depuis référentiel)', 'description': 'Pays de naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}], 'oneOf': [{'type': 'string'}, {'type': 'null'}],
@ -554,7 +558,6 @@ CHILD_SCHEMA = {
'type': 'string', 'type': 'string',
'pattern': '.+', 'pattern': '.+',
}, },
'birth': BIRTH_SCHEMA,
'dietcode': { 'dietcode': {
'description': 'Code de régime alimentaire (depuis référentiel)', 'description': 'Code de régime alimentaire (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}], 'oneOf': [{'type': 'string'}, {'type': 'null'}],

View File

@ -170,6 +170,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
'ChildIndicator', 'ChildIndicator',
'Civility', 'Civility',
'Country', 'Country',
'County',
'CSP', 'CSP',
'DietCode', 'DietCode',
'Document', 'Document',
@ -408,6 +409,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
subscribe_natures[school_year].add(activity_nature['code']) subscribe_natures[school_year].add(activity_nature['code'])
data['subscribe_natures'] = {x: sorted(list(y)) for x, y in subscribe_natures.items()} 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): def add_text_value_to_rl_indicator(self, data):
self.add_text_value('RLIndicator', data, ['code']) 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_text_value_to_child_indicator(indicator)
self.add_indicators_field('ChildIndicator', data) self.add_indicators_field('ChildIndicator', data)
self.add_nature_subscriptions(data) self.add_nature_subscriptions(data)
if data.get('birth') and data['birth'].get('communeCode'): self.add_text_value_to_birth(data)
city = CityModel.objects.filter(code=data['birth']['communeCode']).first()
if city:
data['birth']['zipCode'] = city.zipcode
def add_text_value_to_person(self, data): def add_text_value_to_person(self, data):
self.add_text_value('Civility', data, ['civility']) self.add_text_value('Civility', data, ['civility'])
@ -453,10 +460,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.add_text_value('Quotient', quotient, ['cdquo']) self.add_text_value('Quotient', quotient, ['cdquo'])
self.add_indicators_field('RLIndicator', data) self.add_indicators_field('RLIndicator', data)
self.add_nature_subscriptions(data) self.add_nature_subscriptions(data)
if data.get('birth') and data['birth'].get('communeCode'): self.add_text_value_to_birth(data)
city = CityModel.objects.filter(code=data['birth']['communeCode']).first()
if city:
data['birth']['zipCode'] = city.zipcode
def add_text_value_to_family(self, data): def add_text_value_to_family(self, data):
self.add_text_value('Category', data, ['category']) self.add_text_value('Category', data, ['category'])
@ -554,6 +558,18 @@ class ToulouseMaelis(BaseResource, HTTPResource):
'Vaccin', post_data, keys + ['vaccinList', i, 'code'], required=False '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): def check_and_adapt_child_pai_payoad_in_referential(self, post_data, parent_keys=None):
keys = parent_keys or [] keys = parent_keys or []
self.assert_post_data_in_referential('PAI', post_data, keys + ['code']) self.assert_post_data_in_referential('PAI', post_data, keys + ['code'])
@ -587,6 +603,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
post_data, keys + ['medicalRecord'] post_data, keys + ['medicalRecord']
) )
self.check_and_adapt_update_indicator_payload_in_referential('ChildIndicator', post_data, keys) 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): def check_and_adapt_person_payload_in_referential(self, post_data, parent_keys=None):
keys = parent_keys or [] keys = parent_keys or []
@ -625,6 +642,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.assert_post_data_in_referential('Quality', post_data, keys + ['quality']) 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_coordinate_payload_in_referential(post_data, keys)
self.check_and_adapt_update_indicator_payload_in_referential('RLIndicator', 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): def check_and_adapt_create_rl1_payload_in_referential(self, post_data):
self.assert_post_data_in_referential('Category', post_data, ['category']) 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): def read_country_list(self, request, id=None, q=None, limit=None, distinct=True):
return {'data': self.get_referential('Country', id, q, limit, distinct)} 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 lenregistrement'},
'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( @endpoint(
display_category='Famille', display_category='Famille',
description='Lister les communes', description='Lister les communes',

View File

@ -25,6 +25,18 @@
<code>125</code> <code>125</code>
<libelle>ALBANIE</libelle> <libelle>ALBANIE</libelle>
</itemList> </itemList>
<itemList>
<code>99100</code>
<libelle>FRANCE</libelle>
</itemList>
<itemList>
<code>99350</code>
<libelle>MAROC</libelle>
</itemList>
<itemList>
<code>99351</code>
<libelle>TUNISIE</libelle>
</itemList>
</ns2:readCountryListResponse> </ns2:readCountryListResponse>
</soap:Body> </soap:Body>
</soap:Envelope> </soap:Envelope>

View File

@ -0,0 +1,22 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readCountyListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<itemList>
<code>01</code>
<libelle>AIN</libelle>
</itemList>
<itemList>
<code>02</code>
<libelle>AISNE</libelle>
</itemList>
<itemList>
<code>03</code>
<libelle>ALLIER</libelle>
</itemList>
<itemList>
<code>91</code>
<libelle>ESSONNE</libelle>
</itemList>
</ns2:readCountyListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -17,6 +17,7 @@
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth> <dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
<place>Rabbat</place> <place>Rabbat</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99350</countryCode> <countryCode>99350</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -72,6 +73,7 @@
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth> <dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
<place>Bardot</place> <place>Bardot</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99351</countryCode> <countryCode>99351</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -140,6 +142,7 @@
<dateBirth>1943-01-19T00:00:00+01:00</dateBirth> <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
<place>Saint-louis</place> <place>Saint-louis</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99100</countryCode> <countryCode>99100</countryCode>
</birth> </birth>
<dietcode>RSV</dietcode> <dietcode>RSV</dietcode>

View File

@ -17,6 +17,7 @@
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth> <dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
<place>Rabbat</place> <place>Rabbat</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99350</countryCode> <countryCode>99350</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -72,6 +73,7 @@
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth> <dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
<place>Bardot</place> <place>Bardot</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99351</countryCode> <countryCode>99351</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -140,6 +142,7 @@
<dateBirth>1943-01-19T00:00:00+01:00</dateBirth> <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
<place>Saint-louis</place> <place>Saint-louis</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99100</countryCode> <countryCode>99100</countryCode>
</birth> </birth>
<dietcode>RSV</dietcode> <dietcode>RSV</dietcode>

View File

@ -17,6 +17,7 @@
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth> <dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
<place>Rabbat</place> <place>Rabbat</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99350</countryCode> <countryCode>99350</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -72,6 +73,7 @@
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth> <dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
<place>Bardot</place> <place>Bardot</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99351</countryCode> <countryCode>99351</countryCode>
</birth> </birth>
<adresse> <adresse>
@ -140,6 +142,7 @@
<dateBirth>1943-01-19T00:00:00+01:00</dateBirth> <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
<place>Saint-louis</place> <place>Saint-louis</place>
<communeCode>91122</communeCode> <communeCode>91122</communeCode>
<cdDepartment>91</cdDepartment>
<countryCode>99100</countryCode> <countryCode>99100</countryCode>
</birth> </birth>
<dietcode>RSV</dietcode> <dietcode>RSV</dietcode>

View File

@ -13,6 +13,10 @@
<code>64001</code> <code>64001</code>
<libelle>AAST</libelle> <libelle>AAST</libelle>
</itemList> </itemList>
<itemList>
<code>91122</code>
<libelle>BURES-SUR-YVETTE</libelle>
</itemList>
</ns2:readTownListResponse> </ns2:readTownListResponse>
</soap:Body> </soap:Body>
</soap:Envelope> </soap:Envelope>

View File

@ -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('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('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('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('readDietCodeList', get_xml_file('R_read_dietcode_list.xml'))
soap_mock.add_soap_response('readDocumentList', get_xml_file('R_read_document_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', 'Civility',
'Complement', 'Complement',
'Country', 'Country',
'County',
'DerogReason', 'DerogReason',
'DietCode', 'DietCode',
'Direct', 'Direct',
@ -656,21 +658,34 @@ def test_read_country_list(con, app):
url = get_endpoint('read-country-list') url = get_endpoint('read-country-list')
resp = app.get(url) resp = app.get(url)
assert resp.json['err'] == 0 assert resp.json['err'] == 0
assert len(resp.json['data']) == 3 assert len(resp.json['data']) == 6
assert resp.json['data'] == [ assert resp.json['data'][:3] == [
{'id': '212', 'code': '212', 'text': 'AFGHANISTAN', 'libelle': 'AFGHANISTAN'}, {'id': '212', 'code': '212', 'text': 'AFGHANISTAN', 'libelle': 'AFGHANISTAN'},
{'id': '303', 'code': '303', 'text': 'AFRIQUE DU SUD', 'libelle': 'AFRIQUE DU SUD'}, {'id': '303', 'code': '303', 'text': 'AFRIQUE DU SUD', 'libelle': 'AFRIQUE DU SUD'},
{'id': '125', 'code': '125', 'text': 'ALBANIE', 'libelle': 'ALBANIE'}, {'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): def test_read_town_list(con, app):
url = get_endpoint('read-town-list') url = get_endpoint('read-town-list')
resp = app.get(url) resp = app.get(url)
assert resp.json['err'] == 0 assert resp.json['err'] == 0
assert len(resp.json['data']) == 3 assert len(resp.json['data']) == 4
assert resp.json['data'] == [ assert resp.json['data'] == [
{'code': '64001', 'id': '64001', 'libelle': 'AAST', 'text': 'AAST'}, {'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': '07120', 'id': '07120', 'libelle': 'LACHAMP-RAPHAEL', 'text': 'LACHAMP-RAPHAEL'},
{ {
'code': '69391', 'code': '69391',
@ -689,6 +704,7 @@ def test_read_town_list(con, app):
resp = app.get(url) resp = app.get(url)
assert resp.json['data'] == [ assert resp.json['data'] == [
{'code': '64001', 'id': '64001', 'libelle': 'AAST', 'text': 'AAST'}, {'code': '64001', 'id': '64001', 'libelle': 'AAST', 'text': 'AAST'},
{'code': '91122', 'id': '91122', 'libelle': 'BURES-SUR-YVETTE', 'text': 'BURES-SUR-YVETTE'},
{ {
'code': '07120', 'code': '07120',
'id': '07120', 'id': '07120',
@ -1378,11 +1394,14 @@ def test_read_family(family_service, xml, con, app):
'quality': 'PERE', 'quality': 'PERE',
'civility': 'M.', 'civility': 'M.',
'birth': { 'birth': {
'cdDepartment': None, 'cdDepartment': '91',
'communeCode': '91122', 'communeCode': '91122',
'countryCode': '99350', 'countryCode': '99350',
'dateBirth': '1938-07-26T00:00:00+01:00', 'dateBirth': '1938-07-26T00:00:00+01:00',
'place': 'Rabbat', 'place': 'Rabbat',
'cdDepartment_text': 'ESSONNE',
'communeCode_text': 'BURES-SUR-YVETTE',
'countryCode_text': 'MAROC',
}, },
'adresse': { 'adresse': {
'idStreet': 'AM0330', 'idStreet': 'AM0330',
@ -1494,11 +1513,14 @@ def test_read_family(family_service, xml, con, app):
'sexe': 'F', 'sexe': 'F',
'sexe_text': 'Féminin', 'sexe_text': 'Féminin',
'birth': { 'birth': {
'cdDepartment': None, 'cdDepartment': '91',
'dateBirth': '1943-01-19T00:00:00+01:00', 'dateBirth': '1943-01-19T00:00:00+01:00',
'place': 'Saint-louis', 'place': 'Saint-louis',
'communeCode': '91122', 'communeCode': '91122',
'countryCode': '99100', 'countryCode': '99100',
'cdDepartment_text': 'ESSONNE',
'communeCode_text': 'BURES-SUR-YVETTE',
'countryCode_text': 'FRANCE',
}, },
'dietcode': 'RSV', 'dietcode': 'RSV',
'dietcode_text': '3- RÉGIME SANS VIANDE', 'dietcode_text': '3- RÉGIME SANS VIANDE',
@ -1744,11 +1766,14 @@ def test_read_rl2(family_service, con, app):
'quality': 'MERE', 'quality': 'MERE',
'civility': 'MME', 'civility': 'MME',
'birth': { 'birth': {
'cdDepartment': None, 'cdDepartment': '91',
'communeCode': '91122', 'communeCode': '91122',
'countryCode': '99351', 'countryCode': '99351',
'dateBirth': '1940-06-22T00:00:00+02:00', 'dateBirth': '1940-06-22T00:00:00+02:00',
'place': 'Bardot', 'place': 'Bardot',
'cdDepartment_text': 'ESSONNE',
'communeCode_text': 'BURES-SUR-YVETTE',
'countryCode_text': 'TUNISIE',
}, },
'adresse': { 'adresse': {
'idStreet': None, 'idStreet': None,
@ -2144,6 +2169,7 @@ def test_create_family(family_service, con, app):
'rl1/lastname': 'Doe', 'rl1/lastname': 'Doe',
'rl1/quality': 'AU', 'rl1/quality': 'AU',
'rl1/birth/communeCode': None, 'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350', 'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat', '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/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Saint-louis', 'childList/0/birth/place': 'Saint-louis',
'childList/0/birth/communeCode': '91122', 'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100', 'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV', 'childList/0/dietcode': 'RSV',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC', '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/lastname': 'Doe',
'rl1/quality': 'AU', 'rl1/quality': 'AU',
'rl1/birth/communeCode': None, 'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350', 'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat', '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/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Saint-louis', 'childList/0/birth/place': 'Saint-louis',
'childList/0/birth/communeCode': '91122', 'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100', 'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV', 'childList/0/dietcode': 'RSV',
'childList/0/medicalRecord/vaccinList/0/code': 'plop', '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" == "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 test_update_family(family_service, con, app):
def request_check(request): def request_check(request):
@ -2320,6 +2358,7 @@ def test_update_family(family_service, con, app):
'rl1/lastname': 'Doe', 'rl1/lastname': 'Doe',
'rl1/quality': 'AU', 'rl1/quality': 'AU',
'rl1/birth/communeCode': None, 'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350', 'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat', 'rl1/birth/place': 'Rabbat',
@ -2341,6 +2380,9 @@ def test_update_family(family_service, con, app):
'childList/0/sexe': 'M', 'childList/0/sexe': 'M',
'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Duluth', '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/dietcode': 'RSV',
'childList/0/paiInfoBean/code': 'PAIALI', 'childList/0/paiInfoBean/code': 'PAIALI',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC', '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/lastname': 'Doe',
'rl1/quality': 'AU', 'rl1/quality': 'AU',
'rl1/birth/communeCode': None, 'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350', 'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26', 'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat', 'rl1/birth/place': 'Rabbat',
@ -2462,6 +2505,9 @@ def test_update_family_wrong_referential_key_error(con, app):
'childList/0/sexe': 'M', 'childList/0/sexe': 'M',
'childList/0/birth/dateBirth': '1941-05-24', 'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Duluth', '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/dietcode': 'RSV',
'childList/0/paiInfoBean/code': 'PAIALI', 'childList/0/paiInfoBean/code': 'PAIALI',
'childList/0/medicalRecord/vaccinList/0/code': 'plop', '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" == "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): def test_create_rl1(family_service, con, app):
family_service.add_soap_response('createFamily', get_xml_file('R_create_family.xml')) 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" == "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): def test_create_rl1_maelis_error(family_service, con, app):
family_service.add_soap_response('createFamily', get_xml_file('R_create_family_error.xml')) 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'] == 1
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential" 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): def test_create_child_connection_error(family_service, con, app):
family_service.add_soap_response('createChild', ConnectionError('No address associated with hostname')) family_service.add_soap_response('createChild', ConnectionError('No address associated with hostname'))