Skip empty events in final schedule
This commit is contained in:
parent
37eefe8e08
commit
7fd0e5ecf7
3 changed files with 14 additions and 17 deletions
|
|
@ -79,7 +79,14 @@ def test_create_on_call_shift_override(on_call_shift_internal_api_setup, make_us
|
|||
}
|
||||
|
||||
response = client.post(url, data, format="json", **make_user_auth_headers(user1, token))
|
||||
expected_payload = data | {"id": response.data["id"], "updated_shift": None}
|
||||
returned_rolling_users = response.data["rolling_users"]
|
||||
assert len(returned_rolling_users) == 1
|
||||
assert sorted(returned_rolling_users[0]) == sorted(data["rolling_users"][0])
|
||||
expected_payload = data | {
|
||||
"id": response.data["id"],
|
||||
"updated_shift": None,
|
||||
"rolling_users": returned_rolling_users,
|
||||
}
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert response.json() == expected_payload
|
||||
|
|
@ -1376,14 +1383,7 @@ def test_on_call_shift_preview_without_users(
|
|||
|
||||
# check final schedule events
|
||||
final_events = response.json()["final"]
|
||||
expected_events = [
|
||||
{
|
||||
"end": shift_end,
|
||||
"start": shift_start,
|
||||
"user": None,
|
||||
"is_empty": True,
|
||||
}
|
||||
]
|
||||
expected_events = []
|
||||
returned_events = [
|
||||
{
|
||||
"end": e["end"],
|
||||
|
|
|
|||
|
|
@ -297,6 +297,10 @@ class OnCallSchedule(PolymorphicModel):
|
|||
while pending:
|
||||
ev = pending.pop(0)
|
||||
|
||||
if ev["is_empty"]:
|
||||
# exclude events without active users
|
||||
continue
|
||||
|
||||
if ev["calendar_type"] == OnCallSchedule.TYPE_ICAL_OVERRIDES:
|
||||
# include overrides from start
|
||||
resolved.append(ev)
|
||||
|
|
|
|||
|
|
@ -600,14 +600,7 @@ def test_preview_shift_no_user(make_organization, make_user_for_organization, ma
|
|||
]
|
||||
assert rotation_events == expected_rotation_events
|
||||
|
||||
expected_events = [
|
||||
{
|
||||
"end": new_shift.start + new_shift.duration,
|
||||
"start": new_shift.start,
|
||||
"user": None,
|
||||
"is_empty": True,
|
||||
}
|
||||
]
|
||||
expected_events = []
|
||||
returned_events = [
|
||||
{
|
||||
"end": e["end"],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue