api: fix date_start & meetings/datetimes - again (#53207)
This commit is contained in:
parent
d2643465a0
commit
6554c0a42c
|
@ -170,11 +170,15 @@ def get_all_slots(
|
|||
desk_min_max_datetime[desk] = (now_datetime, now_datetime)
|
||||
continue
|
||||
min_datetime = base.min().replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
if base_min_datetime:
|
||||
min_datetime = max(min_datetime, base_min_datetime)
|
||||
max_datetime = base.max()
|
||||
start_of_day = max_datetime.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
# move to end of the day if max_datetime is not on a day boundary
|
||||
if max_datetime != start_of_day:
|
||||
max_datetime = start_of_day + datetime.timedelta(days=1)
|
||||
if base_max_datetime:
|
||||
max_datetime = min(max_datetime, base_max_datetime)
|
||||
desk_min_max_datetime[desk] = (min_datetime, max_datetime)
|
||||
|
||||
# aggregate already booked time intervals by desk
|
||||
|
|
|
@ -5830,6 +5830,33 @@ def test_meetings_and_virtual_datetimes_date_filter(app):
|
|||
resp = app.get(virtual_api_url, params=params)
|
||||
assert len(resp.json['data']) == 16
|
||||
|
||||
# now check with exceptions in DB
|
||||
TimePeriodException.objects.create(
|
||||
desk=desk_foo,
|
||||
start_datetime=make_aware(datetime.datetime(2017, 5, 22, 10, 0)),
|
||||
end_datetime=make_aware(datetime.datetime(2017, 5, 22, 12, 0)),
|
||||
)
|
||||
|
||||
params = {
|
||||
'date_start': (localtime(now()) + datetime.timedelta(days=2))
|
||||
.replace(hour=12, minute=0, second=0, microsecond=0)
|
||||
.isoformat()
|
||||
}
|
||||
resp = app.get(foo_api_url, params=params)
|
||||
assert len(resp.json['data']) == 8
|
||||
resp = app.get(virtual_api_url, params=params)
|
||||
assert len(resp.json['data']) == 8
|
||||
|
||||
params = {
|
||||
'date_end': (localtime(now()) + datetime.timedelta(days=2))
|
||||
.replace(hour=11, minute=0, second=0, microsecond=0)
|
||||
.isoformat()
|
||||
}
|
||||
resp = app.get(foo_api_url, params=params)
|
||||
assert len(resp.json['data']) == 6
|
||||
resp = app.get(virtual_api_url, params=params)
|
||||
assert len(resp.json['data']) == 6
|
||||
|
||||
|
||||
def test_datetimes_api_meta(app, freezer):
|
||||
# 2017-05-20 -> saturday
|
||||
|
|
Loading…
Reference in New Issue