toulouse-axel: annual booking for next year (#44727)
This commit is contained in:
parent
3bdbd65423
commit
120a9ca048
|
@ -1406,8 +1406,10 @@ class ToulouseAxel(BaseResource):
|
|||
|
||||
# build dates of the period
|
||||
today = datetime.date.today()
|
||||
reference_year = utils.get_reference_year_from_date(today)
|
||||
start_date = today + datetime.timedelta(days=8)
|
||||
start_date_min = today + datetime.timedelta(days=8)
|
||||
start_date = datetime.datetime.strptime(post_data['booking_date'], utils.json_date_format).date()
|
||||
start_date = max(start_date, start_date_min)
|
||||
reference_year = utils.get_reference_year_from_date(start_date)
|
||||
end_date = datetime.date(reference_year+1, 7, 31)
|
||||
|
||||
# get known activities for this child, to have the ids
|
||||
|
|
|
@ -425,7 +425,8 @@ ANNUAL_BOOKING_SCHEMA = {
|
|||
{'type': 'null'},
|
||||
{'type': 'string', 'enum': ['', 'SV', 'AV']}
|
||||
]
|
||||
}
|
||||
},
|
||||
'booking_date': copy.deepcopy(utils.date_type)
|
||||
},
|
||||
'required': ['booking_list_MAT', 'booking_list_MIDI', 'booking_list_SOIR', 'booking_list_GARD', 'child_id']
|
||||
'required': ['booking_list_MAT', 'booking_list_MIDI', 'booking_list_SOIR', 'booking_list_GARD', 'child_id', 'booking_date']
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ def annual_booking_params():
|
|||
'booking_list_GARD': ['3535:GARD:A19P1M4:wednesday'],
|
||||
'child_id': '3535',
|
||||
'regime': 'AV',
|
||||
'booking_date': '2019-08-01',
|
||||
}
|
||||
|
||||
|
||||
|
@ -3882,24 +3883,30 @@ def test_clae_booking_annual_endpoint(app, resource, annual_booking_params, chil
|
|||
assert 'ACTIVITE' not in payload['ENFANT'][0]
|
||||
|
||||
|
||||
def test_clae_booking_annual_reference_year(app, resource, annual_booking_params, child_activities_data):
|
||||
@freezegun.freeze_time('2019-09-01')
|
||||
def test_clae_booking_annual_next_year(app, resource, child_activities_data):
|
||||
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
||||
activities = child_activities_data['ENFANT'][0]
|
||||
with freezegun.freeze_time('2020-04-16'):
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.schemas.reservation_annuelle') as operation:
|
||||
operation.return_value = schemas.OperationResult(json_response={}, xml_request='', xml_response='')
|
||||
app.post_json('/toulouse-axel/test/clae_booking_annual?NameID=yyy', params=annual_booking_params)
|
||||
for activity in activities['ACTIVITE']:
|
||||
activity['DATEDEBUT'] = '2020-08-01'
|
||||
activity['DATEENTREE'] = '2020-08-01'
|
||||
activity['DATEFIN'] = '2021-07-31'
|
||||
activity['DATESORTIE'] = '2021-07-31'
|
||||
annual_booking_params = {
|
||||
'booking_list_MAT': [],
|
||||
'booking_list_MIDI': None,
|
||||
'booking_list_SOIR': None,
|
||||
'booking_list_GARD': None,
|
||||
'child_id': '3535',
|
||||
'regime': 'AV',
|
||||
'booking_date': '2020-08-01',
|
||||
}
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.schemas.reservation_annuelle') as operation:
|
||||
operation.return_value = schemas.OperationResult(json_response={}, xml_request='', xml_response='')
|
||||
app.post_json('/toulouse-axel/test/clae_booking_annual?NameID=yyy', params=annual_booking_params)
|
||||
payload = operation.call_args_list[0][0][1]['PORTAIL']['DUI']
|
||||
assert payload['ENFANT'][0]['ACTIVITE'][0]['PERIODE'][0]['DATEDEBUT'] == '2020-04-24'
|
||||
assert payload['ENFANT'][0]['ACTIVITE'][0]['PERIODE'][0]['DATEDFIN'] == '2020-07-31'
|
||||
with freezegun.freeze_time('2020-08-01'):
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
||||
with mock.patch('passerelle.contrib.toulouse_axel.schemas.reservation_annuelle') as operation:
|
||||
operation.return_value = schemas.OperationResult(json_response={}, xml_request='', xml_response='')
|
||||
app.post_json('/toulouse-axel/test/clae_booking_annual?NameID=yyy', params=annual_booking_params)
|
||||
payload = operation.call_args_list[0][0][1]['PORTAIL']['DUI']
|
||||
assert payload['ENFANT'][0]['ACTIVITE'][0]['PERIODE'][0]['DATEDEBUT'] == '2020-08-09'
|
||||
assert payload['ENFANT'][0]['ACTIVITE'][0]['PERIODE'][0]['DATEDEBUT'] == '2020-08-01'
|
||||
assert payload['ENFANT'][0]['ACTIVITE'][0]['PERIODE'][0]['DATEDFIN'] == '2021-07-31'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue