From 32daaf74ce96c51526ea518eddad521d3ffba9f6 Mon Sep 17 00:00:00 2001 From: Julia Date: Thu, 18 Aug 2022 18:27:34 +0300 Subject: [PATCH] Fix tests --- engine/apps/api/tests/test_oncall_shift.py | 6 ++++++ engine/apps/schedules/models/custom_on_call_shift.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/apps/api/tests/test_oncall_shift.py b/engine/apps/api/tests/test_oncall_shift.py index fe9f77cf..7705cbe5 100644 --- a/engine/apps/api/tests/test_oncall_shift.py +++ b/engine/apps/api/tests/test_oncall_shift.py @@ -455,11 +455,17 @@ def test_update_old_on_call_shift_with_future_version( response = client.put(url, data=data_to_update, format="json", **make_user_auth_headers(user1, token)) + next_shift_start_date = timezone.datetime.combine(next_rotation_start_date.date(), start_date.time()).astimezone( + timezone.pytz.UTC + ) + expected_payload = data_to_update | { "id": new_on_call_shift.public_primary_key, "type": CustomOnCallShift.TYPE_ROLLING_USERS_EVENT, "schedule": schedule.public_primary_key, "updated_shift": None, + "shift_start": next_shift_start_date.strftime("%Y-%m-%dT%H:%M:%SZ"), + "shift_end": (next_shift_start_date + updated_duration).strftime("%Y-%m-%dT%H:%M:%SZ"), } assert response.status_code == status.HTTP_200_OK diff --git a/engine/apps/schedules/models/custom_on_call_shift.py b/engine/apps/schedules/models/custom_on_call_shift.py index 55db9b32..72c9bc8e 100644 --- a/engine/apps/schedules/models/custom_on_call_shift.py +++ b/engine/apps/schedules/models/custom_on_call_shift.py @@ -558,7 +558,7 @@ class CustomOnCallShift(models.Model): instance_data["start"] = timezone.datetime.combine( instance_data["rotation_start"].date(), instance_data["start"].time(), - ) + ).astimezone(pytz.UTC) if self.last_updated_shift is None or self.last_updated_shift.event_is_started: # create new shift