api: fix meetings datetimes on time change (#47875)
This commit is contained in:
parent
b3c2599efc
commit
f1bdcbbc46
|
@ -723,7 +723,10 @@ class SharedTimePeriod(object):
|
|||
|
||||
# make sure datetime in local timezone, it's ABSOLUTELY necessary
|
||||
# to have stable event ids in the API.
|
||||
event_datetime = make_aware(make_naive(real_min_datetime), is_dst=True).replace(
|
||||
real_min_datetime = real_min_datetime.replace(
|
||||
hour=12
|
||||
) # so aware datetime will be int the dst of the day
|
||||
event_datetime = make_aware(make_naive(real_min_datetime)).replace(
|
||||
hour=self.start_time.hour, minute=self.start_time.minute, second=0, microsecond=0
|
||||
)
|
||||
while event_datetime < max_datetime:
|
||||
|
|
|
@ -532,6 +532,69 @@ def test_datetimes_api_meetings_agenda(app, meetings_agenda):
|
|||
assert len(resp.json['data']) == 3
|
||||
|
||||
|
||||
@pytest.mark.freeze_time('2020-10-24') # tomorrow is time change
|
||||
def test_datetimes_api_meetings_agenda_time_change(app):
|
||||
agenda = Agenda.objects.create(
|
||||
label='Agenda', kind='meetings', minimal_booking_delay=0, maximal_booking_delay=3
|
||||
)
|
||||
desk = Desk.objects.create(agenda=agenda, slug='desk')
|
||||
meeting_type = MeetingType.objects.create(agenda=agenda, slug='foo', duration=60)
|
||||
for weekday in [0, 5, 6]: # monday, saturday, sunday
|
||||
TimePeriod.objects.create(
|
||||
weekday=weekday, start_time=datetime.time(9, 0), end_time=datetime.time(10, 00), desk=desk,
|
||||
)
|
||||
TimePeriod.objects.create(
|
||||
weekday=weekday, start_time=datetime.time(14, 0), end_time=datetime.time(15, 00), desk=desk,
|
||||
)
|
||||
|
||||
api_url = '/api/agenda/%s/meetings/%s/datetimes/' % (agenda.slug, meeting_type.slug)
|
||||
resp = app.get(api_url)
|
||||
assert resp.json['data'] == [
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-24-0900/'},
|
||||
'datetime': '2020-10-24 09:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-24-0900',
|
||||
'text': 'Oct. 24, 2020, 9 a.m.',
|
||||
},
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-24-1400/'},
|
||||
'datetime': '2020-10-24 14:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-24-1400',
|
||||
'text': 'Oct. 24, 2020, 2 p.m.',
|
||||
},
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-25-0900/'},
|
||||
'datetime': '2020-10-25 09:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-25-0900',
|
||||
'text': 'Oct. 25, 2020, 9 a.m.',
|
||||
},
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-25-1400/'},
|
||||
'datetime': '2020-10-25 14:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-25-1400',
|
||||
'text': 'Oct. 25, 2020, 2 p.m.',
|
||||
},
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-26-0900/'},
|
||||
'datetime': '2020-10-26 09:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-26-0900',
|
||||
'text': 'Oct. 26, 2020, 9 a.m.',
|
||||
},
|
||||
{
|
||||
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-26-1400/'},
|
||||
'datetime': '2020-10-26 14:00:00',
|
||||
'disabled': False,
|
||||
'id': 'foo:2020-10-26-1400',
|
||||
'text': 'Oct. 26, 2020, 2 p.m.',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_datetimes_api_meetings_agenda_with_resources(app):
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_str = tomorrow.isoformat()
|
||||
|
|
Loading…
Reference in New Issue