wip/76280-parsifal-do-not-crash-on-subscription-info #177

Merged
nroche merged 2 commits from wip/76280-parsifal-do-not-crash-on-subscription-info into main 2023-04-05 15:53:12 +02:00
3 changed files with 55 additions and 4 deletions

View File

@ -3070,8 +3070,9 @@ class ToulouseMaelis(BaseResource, HTTPResource):
day_names = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']
recurrent_week = []
weekly_calendar = response['weeklyCalendarActivity']
if response['calendarGeneration'].get('value') in ('O', 'F') and weekly_calendar:
weekly_calendar = response.get('weeklyCalendarActivity')
calendar_generation = response.get('calendarGeneration')
if calendar_generation and calendar_generation.get('value') in ('O', 'F') and weekly_calendar:
units = []
for item in response.get('unitScheduleList') or []:
key = item['unit']['calendarLetter']

View File

@ -0,0 +1,25 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getPersonUnitInfoResponse xmlns:ns2="activity.ws.maelis.sigec.com" xmlns:ns3="bean.persistence.activity.ws.maelis.sigec.com" xmlns:ns4="bean.persistence.school.ws.maelis.sigec.com">
<getPersonUnitInfoResponseBean>
<controlResult>
<controlOK>false</controlOK>
<message>E1018 : Il existe déjà une inscription à une unité incompatible : ADL PETIT CAPITOLE élémentaire printemps 2023, ADL BAGATELLE élémentaire printemps 2023</message>
</controlResult>
<personInfo>
<idMaelis>705429</idMaelis>
<num>135096</num>
<lastname>ABBOU DELRIEU</lastname>
<firstname>ADAM</firstname>
<dateBirth>2016-03-15T00:00:00+01:00</dateBirth>
<sexe>M</sexe>
</personInfo>
<activity/>
<unit/>
<place/>
<weeklyCalendarActivity/>
<billingInformation/>
</getPersonUnitInfoResponseBean>
</ns2:getPersonUnitInfoResponse>
</soap:Body>
</soap:Envelope>

View File

@ -7049,7 +7049,32 @@ def test_get_person_subscription_info_error(activity_service, con, app):
}
def test_get_person_subscription_info_loisir_not_linked_error(con, app):
def test_get_person_subscription_info_error2(activity_service, con, app):
activity_service.add_soap_response(
'getPersonUnitInfo',
get_xml_file('R_get_person_unit_info_error2.xml'),
)
url = get_endpoint('get-person-subscription-info')
params = {
'NameID': '',
'family_id': '311323',
'person_id': '246423',
'activity_id': 'A10053187087',
'unit_id': 'A10053187241',
'place_id': 'A10053179604',
'ref_date': '2023-01-22',
}
resp = app.get(url, params=params)
assert resp.json['err'] == 0
assert resp.json['data']['controlResult']['controlOK'] is False
assert (
'E1018 : Il existe déjà une inscription à une unité incompatible'
in resp.json['data']['controlResult']['message']
)
def test_get_person_subscription_info_not_linked_error(con, app):
url = get_endpoint('get-person-subscription-info')
params = {
'NameID': 'local',
@ -7065,7 +7090,7 @@ def test_get_person_subscription_info_loisir_not_linked_error(con, app):
assert resp.json['err_desc'] == 'User not linked to family'
def test_get_person_subscription_info_loisir_date_error(con, app):
def test_get_person_subscription_info_date_error(con, app):
url = get_endpoint('get-person-subscription-info')
params = {