toulouse-maelis: add zipcode data to birth details (#76446) #192
|
@ -371,7 +371,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
result[item['id']] = item
|
||||
data['indicators'] = result
|
||||
|
||||
def add_nature_subsciptions(self, data):
|
||||
def add_nature_subscriptions(self, data):
|
||||
subscribe_natures = {}
|
||||
for item in data['subscribeActivityList'] or []:
|
||||
activity_type = item.get('typeActivity')
|
||||
|
@ -410,7 +410,11 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
for indicator in data['indicatorList']:
|
||||
self.add_text_value_to_child_indicator(indicator)
|
||||
self.add_indicators_field('ChildIndicator', data)
|
||||
self.add_nature_subsciptions(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
|
||||
|
||||
def add_text_value_to_person(self, data):
|
||||
self.add_text_value('Civility', data, ['civility'])
|
||||
|
@ -430,7 +434,11 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
for quotient in data['quotientList']:
|
||||
self.add_text_value('Quotient', quotient, ['cdquo'])
|
||||
self.add_indicators_field('RLIndicator', data)
|
||||
self.add_nature_subsciptions(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
|
||||
|
||||
def add_text_value_to_family(self, data):
|
||||
self.add_text_value('Category', data, ['category'])
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<birth>
|
||||
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
|
||||
<place>Rabbat</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99350</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<birth>
|
||||
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
|
||||
<place>Bardot</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99351</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<birth>
|
||||
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
|
||||
<place>Rabbat</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99350</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<birth>
|
||||
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
|
||||
<place>Bardot</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99351</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<birth>
|
||||
<dateBirth>1938-07-26T00:00:00+01:00</dateBirth>
|
||||
<place>Rabbat</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99350</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<birth>
|
||||
<dateBirth>1940-06-22T00:00:00+02:00</dateBirth>
|
||||
<place>Bardot</place>
|
||||
<communeCode>91122</communeCode>
|
||||
<countryCode>99351</countryCode>
|
||||
</birth>
|
||||
<adresse>
|
||||
|
|
|
@ -1371,7 +1371,7 @@ def test_read_family(family_service, xml, con, app):
|
|||
'civility': 'M.',
|
||||
'birth': {
|
||||
'cdDepartment': None,
|
||||
'communeCode': None,
|
||||
'communeCode': '91122',
|
||||
'countryCode': '99350',
|
||||
'dateBirth': '1938-07-26T00:00:00+01:00',
|
||||
'place': 'Rabbat',
|
||||
|
@ -1634,6 +1634,19 @@ def test_read_family(family_service, xml, con, app):
|
|||
}
|
||||
|
||||
|
||||
def test_read_family_zipcode(family_service, con, app):
|
||||
family_service.add_soap_response('readFamily', get_xml_file("R_read_family.xml"))
|
||||
url = get_endpoint('read-family')
|
||||
|
||||
ban = BaseAdresse.objects.create(slug='ban')
|
||||
CityModel.objects.create(
|
||||
name='Bures-sur-Yvette', code='91122', zipcode='91440', population=96866, resource=ban
|
||||
)
|
||||
|
||||
resp = app.get(url + '?family_id=1312')
|
||||
assert resp.json['data']['RL1']['birth']['zipCode'] == '91440'
|
||||
|
||||
|
||||
def test_read_family_not_linked_error(con, app):
|
||||
url = get_endpoint('read-family')
|
||||
|
||||
|
@ -1724,7 +1737,7 @@ def test_read_rl2(family_service, con, app):
|
|||
'civility': 'MME',
|
||||
'birth': {
|
||||
'cdDepartment': None,
|
||||
'communeCode': None,
|
||||
'communeCode': '91122',
|
||||
'countryCode': '99351',
|
||||
'dateBirth': '1940-06-22T00:00:00+02:00',
|
||||
'place': 'Bardot',
|
||||
|
@ -1989,6 +2002,21 @@ def test_read_child(family_service, con, app):
|
|||
assert resp.json['data']['firstname'] == 'JANNIS'
|
||||
|
||||
|
||||
def test_read_child_zipcode(family_service, con, app):
|
||||
family_service.add_soap_response('readFamily', get_xml_file('R_read_family.xml'))
|
||||
url = get_endpoint('read-child')
|
||||
|
||||
ban = BaseAdresse.objects.create(slug='ban')
|
||||
CityModel.objects.create(
|
||||
name='Bures-sur-Yvette', code='91122', zipcode='91440', population=96866, resource=ban
|
||||
)
|
||||
|
||||
resp = app.get(url + '?family_id=1312&child_id=613880')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data']['firstname'] == 'JANNIS'
|
||||
assert resp.json['data']['birth'].get('zipCode') == '91440'
|
||||
|
||||
|
||||
def test_read_child_not_linked_error(con, app):
|
||||
url = get_endpoint('read-child')
|
||||
|
||||
|
|
Loading…
Reference in New Issue