Skip to content

Commit

Permalink
Merge pull request #222 from voynow/219-speed-up-new-plan-generation
Browse files Browse the repository at this point in the history
fixing tests + device token hotfix
  • Loading branch information
voynow authored Jan 31, 2025
2 parents b5a5fcb + ed43dde commit e5b2323
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ pytest-cov = "^6.0.0"
log_cli = true
log_cli_level = "INFO"
addopts = "--cov=src"
asyncio_mode = "auto"
markers = ["asyncio: mark test as async"]
6 changes: 3 additions & 3 deletions api/src/supabase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def update_user_device_token(athlete_id: str, device_token: str) -> None:
:param athlete_id: The athlete's ID
:param device_token: The device token for push notifications
"""
client.table("user_auth").update({"device_token": device_token}).eq(
"athlete_id", athlete_id
).execute()
client.table(supabase_helpers.get_user_table_name()).update(
{"device_token": device_token}
).eq("athlete_id", athlete_id).execute()


def update_preferences(athlete_id: int, preferences: dict):
Expand Down
2 changes: 1 addition & 1 deletion api/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_get_profile():
"""Test successful retrieval of profile"""
user_auth = supabase_client.get_user(os.environ["JAMIES_ATHLETE_ID"])
response = client.get(
"/profile/", headers={"Authorization": f"Bearer {user_auth.jwt_token}"}
"/v2/profile/", headers={"Authorization": f"Bearer {user_auth.jwt_token}"}
)
assert response.status_code == 200

Expand Down
12 changes: 8 additions & 4 deletions api/tests/test_update_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ def setup_test_environment():
auth_manager.authenticate_athlete(os.environ["JAMIES_ATHLETE_ID"])


def test_update_training_week_gen_training_plan():
@pytest.mark.asyncio
async def test_update_training_week_gen_training_plan():
"""
gen_training_plan_pipeline is called when the race date & distance are set
"""
user = supabase_client.get_user(os.environ["JAMIES_ATHLETE_ID"])
response = _update_training_week(user, ExeType.NEW_WEEK, dt=get_last_sunday())
response = await _update_training_week(user, ExeType.NEW_WEEK, dt=get_last_sunday())
assert isinstance(response, FullTrainingWeek)


def test_update_training_week_mid_week():
@pytest.mark.asyncio
async def test_update_training_week_mid_week():
"""
Test successful update of mid week
This is the only mid week update path
"""
user = supabase_client.get_user(os.environ["JAMIES_ATHLETE_ID"])
response = _update_training_week(user, ExeType.MID_WEEK, dt=datetime_now_est())
response = await _update_training_week(
user, ExeType.MID_WEEK, dt=datetime_now_est()
)
assert isinstance(response, FullTrainingWeek)

0 comments on commit e5b2323

Please sign in to comment.