From 2a3fc397db988364a5494e65fd489fa6603ae03d Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Mon, 3 Oct 2022 15:00:23 -0300 Subject: [PATCH] Clear users cache before schedule tests logic/asserts --- engine/apps/api/tests/test_schedules.py | 2 ++ engine/apps/schedules/tests/test_on_call_schedule.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/engine/apps/api/tests/test_schedules.py b/engine/apps/api/tests/test_schedules.py index 19537391..13ef0825 100644 --- a/engine/apps/api/tests/test_schedules.py +++ b/engine/apps/api/tests/test_schedules.py @@ -985,6 +985,8 @@ def test_merging_same_shift_events( user_a = make_user_for_organization(organization) user_b = make_user_for_organization(organization) user_c = make_user_for_organization(organization, role=Role.VIEWER) + # clear users pks <-> organization cache (persisting between tests) + memoized_users_in_ical.cache_clear() data = { "start": start_date + timezone.timedelta(hours=10), diff --git a/engine/apps/schedules/tests/test_on_call_schedule.py b/engine/apps/schedules/tests/test_on_call_schedule.py index a5380a7e..8bb079f4 100644 --- a/engine/apps/schedules/tests/test_on_call_schedule.py +++ b/engine/apps/schedules/tests/test_on_call_schedule.py @@ -271,6 +271,8 @@ def test_final_schedule_events(make_organization, make_user_for_organization, ma start_date = now - timezone.timedelta(days=7) user_a, user_b, user_c, user_d, user_e = (make_user_for_organization(organization, username=i) for i in "ABCDE") + # clear users pks <-> organization cache (persisting between tests) + memoized_users_in_ical.cache_clear() shifts = ( # user, priority, start time (h), duration (hs) @@ -370,6 +372,8 @@ def test_final_schedule_splitting_events( start_date = now - timezone.timedelta(days=7) user_a, user_b, user_c = (make_user_for_organization(organization, username=i) for i in "ABC") + # clear users pks <-> organization cache (persisting between tests) + memoized_users_in_ical.cache_clear() shifts = ( # user, priority, start time (h), duration (hs) @@ -437,6 +441,8 @@ def test_final_schedule_splitting_same_time_events( start_date = now - timezone.timedelta(days=7) user_a, user_b, user_c = (make_user_for_organization(organization, username=i) for i in "ABC") + # clear users pks <-> organization cache (persisting between tests) + memoized_users_in_ical.cache_clear() shifts = ( # user, priority, start time (h), duration (hs) @@ -771,6 +777,8 @@ def test_schedule_related_users(make_organization, make_user_for_organization, m start_date = now - timezone.timedelta(days=7) user_a, _, _, user_d, user_e = (make_user_for_organization(organization, username=i) for i in "ABCDE") + # clear users pks <-> organization cache (persisting between tests) + memoized_users_in_ical.cache_clear() shifts = ( # user, priority, start time (h), duration (hs)