caluire-axel: fix timezone issue (#55549)
This commit is contained in:
parent
b0da466dae
commit
966b2d72b2
|
@ -23,7 +23,7 @@ from django.core.cache import cache
|
|||
from django.db import models
|
||||
from django.http import HttpResponse
|
||||
from django.utils import dateformat
|
||||
from django.utils.timezone import now
|
||||
from django.utils.timezone import localtime, now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from passerelle.base.models import BaseResource
|
||||
|
@ -583,7 +583,7 @@ class CaluireAxel(BaseResource):
|
|||
raise APIError('Wrong agenda status', err_code='agenda-code-error-%s' % code)
|
||||
|
||||
# get pivot date
|
||||
date_now = now()
|
||||
date_now = localtime(now())
|
||||
pivot_date = None
|
||||
if activity_id.startswith('CJ'):
|
||||
# mercredi or vacances: not bookable
|
||||
|
|
|
@ -1178,45 +1178,47 @@ def test_get_agenda_endpoint_status(app, resource, family_data, activities, valu
|
|||
'today, hour, booking_date, out_of_delay',
|
||||
[
|
||||
# monday 12H => thursday
|
||||
('2021-05-31', '11:59:59', '2021-06-03', False),
|
||||
('2021-05-31', '12:00:00', '2021-06-03', True),
|
||||
('2021-05-31', '09:59:59', '2021-06-03', False),
|
||||
('2021-05-31', '10:00:00', '2021-06-03', True),
|
||||
# tuesday 12H => friday
|
||||
('2021-06-01', '11:59:59', '2021-06-04', False),
|
||||
('2021-06-01', '12:00:00', '2021-06-04', True),
|
||||
('2021-06-01', '09:59:59', '2021-06-04', False),
|
||||
('2021-06-01', '10:00:00', '2021-06-04', True),
|
||||
# wednesday => monday
|
||||
('2021-06-02', '11:59:59', '2021-06-04', True),
|
||||
('2021-06-02', '12:00:00', '2021-06-04', True),
|
||||
('2021-06-02', '11:59:59', '2021-06-05', True),
|
||||
('2021-06-02', '12:00:00', '2021-06-05', True),
|
||||
('2021-06-02', '11:59:59', '2021-06-06', True),
|
||||
('2021-06-02', '12:00:00', '2021-06-06', True),
|
||||
('2021-06-02', '11:59:59', '2021-06-07', False),
|
||||
('2021-06-02', '12:00:00', '2021-06-07', False),
|
||||
('2021-06-02', '09:59:59', '2021-06-04', True),
|
||||
('2021-06-02', '10:00:00', '2021-06-04', True),
|
||||
('2021-06-02', '09:59:59', '2021-06-05', True),
|
||||
('2021-06-02', '10:00:00', '2021-06-05', True),
|
||||
('2021-06-02', '09:59:59', '2021-06-06', True),
|
||||
('2021-06-02', '10:00:00', '2021-06-06', True),
|
||||
('2021-06-02', '09:59:59', '2021-06-07', False),
|
||||
('2021-06-02', '10:00:00', '2021-06-07', False),
|
||||
# thursday 12H => monday
|
||||
('2021-06-03', '11:59:59', '2021-06-07', False),
|
||||
('2021-06-03', '12:00:00', '2021-06-07', True),
|
||||
('2021-06-03', '09:59:59', '2021-06-07', False),
|
||||
('2021-06-03', '10:00:00', '2021-06-07', True),
|
||||
# friday 12H => tuesday
|
||||
('2021-06-04', '11:59:59', '2021-06-08', False),
|
||||
('2021-06-04', '12:00:00', '2021-06-08', True),
|
||||
('2021-06-04', '09:59:59', '2021-06-08', False),
|
||||
('2021-06-04', '10:00:00', '2021-06-08', True),
|
||||
# saturday => thursday
|
||||
('2021-06-05', '11:59:59', '2021-06-08', True),
|
||||
('2021-06-05', '12:00:00', '2021-06-08', True),
|
||||
('2021-06-05', '11:59:59', '2021-06-09', True),
|
||||
('2021-06-05', '12:00:00', '2021-06-09', True),
|
||||
('2021-06-05', '11:59:59', '2021-06-10', False),
|
||||
('2021-06-05', '12:00:00', '2021-06-10', False),
|
||||
('2021-06-05', '09:59:59', '2021-06-08', True),
|
||||
('2021-06-05', '10:00:00', '2021-06-08', True),
|
||||
('2021-06-05', '09:59:59', '2021-06-09', True),
|
||||
('2021-06-05', '10:00:00', '2021-06-09', True),
|
||||
('2021-06-05', '09:59:59', '2021-06-10', False),
|
||||
('2021-06-05', '10:00:00', '2021-06-10', False),
|
||||
# sunday => thursday
|
||||
('2021-06-06', '11:59:59', '2021-06-08', True),
|
||||
('2021-06-06', '12:00:00', '2021-06-08', True),
|
||||
('2021-06-06', '11:59:59', '2021-06-09', True),
|
||||
('2021-06-06', '12:00:00', '2021-06-09', True),
|
||||
('2021-06-06', '11:59:59', '2021-06-10', False),
|
||||
('2021-06-06', '12:00:00', '2021-06-10', False),
|
||||
('2021-06-06', '09:59:59', '2021-06-08', True),
|
||||
('2021-06-06', '10:00:00', '2021-06-08', True),
|
||||
('2021-06-06', '09:59:59', '2021-06-09', True),
|
||||
('2021-06-06', '10:00:00', '2021-06-09', True),
|
||||
('2021-06-06', '09:59:59', '2021-06-10', False),
|
||||
('2021-06-06', '10:00:00', '2021-06-10', False),
|
||||
],
|
||||
)
|
||||
def test_get_agenda_endpoint_delay_periscolaire(
|
||||
app, resource, family_data, activities_full, today, hour, booking_date, out_of_delay
|
||||
settings, app, resource, family_data, activities_full, today, hour, booking_date, out_of_delay
|
||||
):
|
||||
settings.TIME_ZONE = 'Europe/Paris'
|
||||
settings.USE_TZ = True
|
||||
booking = datetime.datetime.strptime(booking_date, json_date_format).date()
|
||||
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
||||
content = '''<PORTAIL>
|
||||
|
|
Loading…
Reference in New Issue