test(api): fix ruff issues in routine tests
This commit is contained in:
parent
472a3034a0
commit
9bbc34ffd2
2 changed files with 61 additions and 38 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import uuid
|
||||
from unittest.mock import patch
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Routines
|
||||
|
|
@ -217,12 +218,17 @@ def test_delete_grooming_schedule_not_found(client):
|
|||
r = client.delete(f"/routines/grooming-schedule/{uuid.uuid4()}")
|
||||
assert r.status_code == 404
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
def test_suggest_routine(client, session):
|
||||
with patch("innercontext.api.routines.call_gemini") as mock_gemini:
|
||||
# Mock the Gemini response
|
||||
mock_response = type("Response", (), {"text": '{"steps": [{"product_id": null, "action_type": "shaving_razor"}], "reasoning": "because"}'})
|
||||
mock_response = type(
|
||||
"Response",
|
||||
(),
|
||||
{
|
||||
"text": '{"steps": [{"product_id": null, "action_type": "shaving_razor"}], "reasoning": "because"}'
|
||||
},
|
||||
)
|
||||
mock_gemini.return_value = mock_response
|
||||
|
||||
r = client.post(
|
||||
|
|
@ -231,8 +237,8 @@ def test_suggest_routine(client, session):
|
|||
"routine_date": "2026-03-03",
|
||||
"part_of_day": "am",
|
||||
"notes": "Testing",
|
||||
"include_minoxidil_beard": True
|
||||
}
|
||||
"include_minoxidil_beard": True,
|
||||
},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
data = r.json()
|
||||
|
|
@ -240,10 +246,17 @@ def test_suggest_routine(client, session):
|
|||
assert data["steps"][0]["action_type"] == "shaving_razor"
|
||||
assert data["reasoning"] == "because"
|
||||
|
||||
|
||||
def test_suggest_batch(client, session):
|
||||
with patch("innercontext.api.routines.call_gemini") as mock_gemini:
|
||||
# Mock the Gemini response
|
||||
mock_response = type("Response", (), {"text": '{"days": [{"date": "2026-03-03", "am_steps": [], "pm_steps": [], "reasoning": "none"}], "overall_reasoning": "batch test"}'})
|
||||
mock_response = type(
|
||||
"Response",
|
||||
(),
|
||||
{
|
||||
"text": '{"days": [{"date": "2026-03-03", "am_steps": [], "pm_steps": [], "reasoning": "none"}], "overall_reasoning": "batch test"}'
|
||||
},
|
||||
)
|
||||
mock_gemini.return_value = mock_response
|
||||
|
||||
r = client.post(
|
||||
|
|
@ -251,8 +264,8 @@ def test_suggest_batch(client, session):
|
|||
json={
|
||||
"from_date": "2026-03-03",
|
||||
"to_date": "2026-03-04",
|
||||
"minimize_products": True
|
||||
}
|
||||
"minimize_products": True,
|
||||
},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
data = r.json()
|
||||
|
|
@ -260,16 +273,18 @@ def test_suggest_batch(client, session):
|
|||
assert data["days"][0]["date"] == "2026-03-03"
|
||||
assert data["overall_reasoning"] == "batch test"
|
||||
|
||||
|
||||
def test_suggest_batch_invalid_date_range(client):
|
||||
r = client.post(
|
||||
"/routines/suggest-batch",
|
||||
json={"from_date": "2026-03-04", "to_date": "2026-03-03"}
|
||||
json={"from_date": "2026-03-04", "to_date": "2026-03-03"},
|
||||
)
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
def test_suggest_batch_too_long(client):
|
||||
r = client.post(
|
||||
"/routines/suggest-batch",
|
||||
json={"from_date": "2026-03-01", "to_date": "2026-03-20"}
|
||||
json={"from_date": "2026-03-01", "to_date": "2026-03-20"},
|
||||
)
|
||||
assert r.status_code == 400
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue