toulouse-maelis: do not crash on unbounded subscribed activity (#79088)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Nicolas Roche 2023-06-27 18:07:06 +02:00 committed by Nicolas Roche
parent bd388e42a6
commit 25420ca260
5 changed files with 81 additions and 6 deletions

View File

@ -429,10 +429,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
if not activity_nature:
continue
for unit in item['subscribesUnit']:
start_year = utils.get_reference_year_from_date(unit.get('dateStart'))
end_year = utils.get_reference_year_from_date(unit.get('dateEnd'))
if not start_year or not end_year:
start_date = unit.get('dateStart')
end_date = unit.get('dateEnd')
if not start_date or not end_date:
continue
start_year = utils.get_reference_year_from_date(start_date)
end_year = utils.get_reference_year_from_date(end_date)
for year in range(start_year, end_year + 1):
school_year = '%s-%s' % (year, year + 1)
if not subscribe_natures.get(school_year):
@ -1452,10 +1454,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
if school_year:
school_years = set()
for unit in item['subscribesUnit']:
start_year = utils.get_reference_year_from_date(unit.get('dateStart'))
end_year = utils.get_reference_year_from_date(unit.get('dateEnd'))
if not start_year or not end_year:
start_date = unit.get('dateStart')
end_date = unit.get('dateEnd')
if not start_date or not end_date:
continue
start_year = utils.get_reference_year_from_date(start_date)
end_year = utils.get_reference_year_from_date(end_date)
for year in range(start_year, end_year + 1):
school_years.add('%s-%s' % (year, year + 1))
if school_year not in school_years:

View File

@ -378,6 +378,29 @@
</natureSpec>
</typeActivity>
</subscribeActivityList>
<subscribeActivityList>
<libelle>M.A ARNAUD BERNARD</libelle>
<typeIns>1</typeIns>
<libelleTypeIns>DEFINITIVE</libelleTypeIns>
<subscribesUnit>
<idUnit>M10056519833</idUnit>
<libelle>M.A ARNAUD BERNARD</libelle>
<bUniStd>true</bUniStd>
<dateStart>2023-06-20T00:00:00+02:00</dateStart>
</subscribesUnit>
<place>M.A ARNAUD BERNARD</place>
<typeConsum>ENF</typeConsum>
<libelleTypeConsum>ENFANT</libelleTypeConsum>
<idActivity>M10000000109</idActivity>
<typeActivity>
<code>CRECHCO</code>
<libelle>Crèche collective</libelle>
<natureSpec>
<code>E</code>
<libelle>Petite Enfance</libelle>
</natureSpec>
</typeActivity>
</subscribeActivityList>
</childList>
<childList>
<num>613987</num>

View File

@ -377,6 +377,29 @@
</natureSpec>
</typeActivity>
</subscribeActivityList>
<subscribeActivityList>
<libelle>M.A ARNAUD BERNARD</libelle>
<typeIns>1</typeIns>
<libelleTypeIns>DEFINITIVE</libelleTypeIns>
<subscribesUnit>
<idUnit>M10056519833</idUnit>
<libelle>M.A ARNAUD BERNARD</libelle>
<bUniStd>true</bUniStd>
<dateStart>2023-06-20T00:00:00+02:00</dateStart>
</subscribesUnit>
<place>M.A ARNAUD BERNARD</place>
<typeConsum>ENF</typeConsum>
<libelleTypeConsum>ENFANT</libelleTypeConsum>
<idActivity>M10000000109</idActivity>
<typeActivity>
<code>CRECHCO</code>
<libelle>Crèche collective</libelle>
<natureSpec>
<code>E</code>
<libelle>Petite Enfance</libelle>
</natureSpec>
</typeActivity>
</subscribeActivityList>
</childList>
<childList>
<num>613987</num>

View File

@ -378,6 +378,29 @@
</natureSpec>
</typeActivity>
</subscribeActivityList>
<subscribeActivityList>
<libelle>M.A ARNAUD BERNARD</libelle>
<typeIns>1</typeIns>
<libelleTypeIns>DEFINITIVE</libelleTypeIns>
<subscribesUnit>
<idUnit>M10056519833</idUnit>
<libelle>M.A ARNAUD BERNARD</libelle>
<bUniStd>true</bUniStd>
<dateStart>2023-06-20T00:00:00+02:00</dateStart>
</subscribesUnit>
<place>M.A ARNAUD BERNARD</place>
<typeConsum>ENF</typeConsum>
<libelleTypeConsum>ENFANT</libelleTypeConsum>
<idActivity>M10000000109</idActivity>
<typeActivity>
<code>CRECHCO</code>
<libelle>Crèche collective</libelle>
<natureSpec>
<code>E</code>
<libelle>Petite Enfance</libelle>
</natureSpec>
</typeActivity>
</subscribeActivityList>
</childList>
<childList>
<num>613987</num>

View File

@ -1759,6 +1759,7 @@ def test_read_family(family_service, xml, con, app):
('A', 'CLAE MATIN 22/23'),
('X', 'SEMST2 ADL MERC. ELEM Maourine 22/23'),
('8', 'ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES'),
('E', 'M.A ARNAUD BERNARD'),
]
assert resp.json['data']['childList'][0]['subscribe_natures'] == {
'2022-2023': ['8', 'A', 'R', 'X'],
@ -2032,6 +2033,7 @@ def test_read_subscribe_activity_list(family_service, con, app):
('A10049327689', 'CLAE MATIN 22/23', 'A', 'ACCMAT'),
('A10049354913', 'SEMST2 ADL MERC. ELEM Maourine 22/23', 'X', 'EXTMERC'),
('A10053179798', 'ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES', '8', '25'),
('M10000000109', 'M.A ARNAUD BERNARD', 'E', 'CRECHCO'),
]
resp = app.get(url + '?NameID=local&person_id=613880&nature=PERISCO')