toulouse-maelis: allow activity booking on civil year (#78579)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5d05b38653
commit
0616f216bf
|
@ -3546,8 +3546,8 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
parameters={
|
||||
'person_id': {'description': "Numéro du responsable légal ou de l'enfant"},
|
||||
'activity_id': {'description': "Numéro de l'activité"},
|
||||
'start_date': {'description': 'Début de la période'},
|
||||
'end_date': {'description': 'Fin de la période'},
|
||||
'start_date': {'description': 'Début de la période', 'type': 'date'},
|
||||
'end_date': {'description': 'Fin de la période', 'type': 'date'},
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
},
|
||||
|
@ -3556,14 +3556,14 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self, request, person_id, activity_id, start_date, end_date, NameID=None, family_id=None
|
||||
):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
start_date, end_date, reference_year = self.get_start_and_end_dates(start_date, end_date)
|
||||
if start_date > end_date:
|
||||
raise APIError('start_date should be before end_date', http_status=400)
|
||||
bookings = self.get_activity_bookings(family_id, person_id, activity_id, start_date, end_date)
|
||||
return {
|
||||
'data': bookings,
|
||||
'extra_data': {
|
||||
'start_date': start_date,
|
||||
'end_date': end_date,
|
||||
'school_year': '%s/%s' % (reference_year, reference_year + 1),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -8551,7 +8551,6 @@ def test_read_activity_agenda(activity_service, con, app):
|
|||
assert resp.json['extra_data'] == {
|
||||
'start_date': '2023-05-01',
|
||||
'end_date': '2023-05-31',
|
||||
'school_year': '2022/2023',
|
||||
}
|
||||
assert len(resp.json['data']) == 4
|
||||
assert resp.json['data'] == [
|
||||
|
@ -8671,7 +8670,6 @@ def test_read_activity_agenda_multi_units(activity_service, con, app):
|
|||
assert resp.json['extra_data'] == {
|
||||
'start_date': '2023-04-01',
|
||||
'end_date': '2023-04-30',
|
||||
'school_year': '2022/2023',
|
||||
}
|
||||
assert len(resp.json['data']) == 10
|
||||
assert resp.json['data'][:8] == [
|
||||
|
@ -8862,6 +8860,30 @@ def test_read_activity_agenda_multi_units(activity_service, con, app):
|
|||
]
|
||||
|
||||
|
||||
def test_read_activity_agenda_on_civil_year(activity_service, con, app):
|
||||
activity_service.add_soap_response(
|
||||
'getPersonScheduleList', get_xml_file('R_get_person_schedule_list_on_activity.xml')
|
||||
)
|
||||
url = get_endpoint('read-activity-agenda')
|
||||
params = {
|
||||
'person_id': '261768',
|
||||
'activity_id': 'A10049354913',
|
||||
'start_date': '2023-01-01',
|
||||
'end_date': '2023-12-31',
|
||||
}
|
||||
|
||||
resp = app.get(url + '?family_id=1312', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
||||
resp = app.get(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['extra_data'] == {
|
||||
'start_date': '2023-01-01',
|
||||
'end_date': '2023-12-31',
|
||||
}
|
||||
|
||||
|
||||
def test_read_activity_agenda_not_linked_error(con, app):
|
||||
url = get_endpoint('read-activity-agenda')
|
||||
|
||||
|
@ -8883,13 +8905,13 @@ def test_read_activity_agenda_date_error(con, app):
|
|||
}
|
||||
resp = app.get(url + '?family_id=1312', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'bad date format, should be YYYY-MM-DD'
|
||||
assert resp.json['err_desc'] == 'invalid value for parameter "start_date (YYYY-MM-DD expected)"'
|
||||
|
||||
params['start_date'] = '2022-09-01'
|
||||
params['end_date'] = 'bad'
|
||||
resp = app.get(url + '?family_id=1312', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'bad date format, should be YYYY-MM-DD'
|
||||
assert resp.json['err_desc'] == 'invalid value for parameter "end_date (YYYY-MM-DD expected)"'
|
||||
|
||||
params['start_date'] = '2023-09-01'
|
||||
params['end_date'] = '2023-08-31'
|
||||
|
@ -8897,12 +8919,6 @@ def test_read_activity_agenda_date_error(con, app):
|
|||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'start_date should be before end_date'
|
||||
|
||||
params['start_date'] = '2022-09-01'
|
||||
params['end_date'] = ('2024-08-31',)
|
||||
resp = app.get(url + '?family_id=1312', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'start_date and end_date are in different reference year (2022 != 2023)'
|
||||
|
||||
|
||||
def test_read_activity_agenda_empty(activity_service, con, app):
|
||||
activity_service.add_soap_response(
|
||||
|
|
Loading…
Reference in New Issue