From b271abd5c3c183e3b1b4d5d836bbd4ea40e81816 Mon Sep 17 00:00:00 2001 From: voynow Date: Sun, 2 Feb 2025 13:00:17 -0500 Subject: [PATCH] ugh another fix --- api/src/update_pipeline.py | 6 ++++-- api/tests/test_update_pipeline.py | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/api/src/update_pipeline.py b/api/src/update_pipeline.py index 0533eee..3211d37 100644 --- a/api/src/update_pipeline.py +++ b/api/src/update_pipeline.py @@ -163,8 +163,10 @@ async def refresh_user_data( user=user, daily_activity=daily_activity, mileage_rec=mileage_rec, - exe_type=ExeType.MID_WEEK, - dt=dt_tomorrow, + exe_type=( + ExeType.NEW_WEEK if dt.weekday() == 6 else ExeType.MID_WEEK + ), # step into next week on sundays + dt=dt, ) supabase_client.upsert_training_week( diff --git a/api/tests/test_update_pipeline.py b/api/tests/test_update_pipeline.py index 54d301a..df7ff1e 100644 --- a/api/tests/test_update_pipeline.py +++ b/api/tests/test_update_pipeline.py @@ -22,6 +22,17 @@ def setup_test_environment(): auth_manager.authenticate_athlete(os.environ["JAMIES_ATHLETE_ID"]) +@pytest.mark.asyncio +async def test_refresh_user_data_on_sunday(): + """ + Test successful refresh of user data + """ + delete_test_user_training_plans() + user = supabase_client.get_user(os.environ["TEST_USER_ATHLETE_ID"]) + response = await refresh_user_data(user, dt=get_last_sunday()) + assert isinstance(response, dict) + + @pytest.mark.asyncio async def test_update_training_week_gen_training_plan(): """ @@ -46,17 +57,6 @@ async def test_update_training_week_mid_week(): assert isinstance(response, FullTrainingWeek) -@pytest.mark.asyncio -async def test_refresh_user_data_on_sunday(): - """ - Test successful refresh of user data - """ - delete_test_user_training_plans() - user = supabase_client.get_user(os.environ["TEST_USER_ATHLETE_ID"]) - response = await refresh_user_data(user, dt=get_last_sunday()) - assert isinstance(response, dict) - - @pytest.mark.asyncio async def test_refresh_user_data_on_monday(): """