mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 21:45:25 +02:00
chore(deps): update dependency ruff to ^0.9.0 (#4871)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
ea0bec2336
commit
2c2de1e95b
22 changed files with 124 additions and 138 deletions
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import UUID4
|
||||
|
@ -34,10 +34,10 @@ def test_new_mealplan_event(api_client: TestClient, unique_user: TestUser):
|
|||
response_json = response.json()
|
||||
initial_event_count = len(response_json["items"])
|
||||
|
||||
new_plan = CreatePlanEntry(
|
||||
date=datetime.now(timezone.utc).date(), entry_type="dinner", recipe_id=recipe_id
|
||||
).model_dump(by_alias=True)
|
||||
new_plan["date"] = datetime.now(timezone.utc).date().isoformat()
|
||||
new_plan = CreatePlanEntry(date=datetime.now(UTC).date(), entry_type="dinner", recipe_id=recipe_id).model_dump(
|
||||
by_alias=True
|
||||
)
|
||||
new_plan["date"] = datetime.now(UTC).date().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
response = api_client.post(api_routes.households_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
@ -65,7 +65,7 @@ def test_new_mealplan_event(api_client: TestClient, unique_user: TestUser):
|
|||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
new_recipe_data: dict = response.json()
|
||||
recipe = RecipeSummary.model_validate(new_recipe_data)
|
||||
assert recipe.last_made.date() == datetime.now(timezone.utc).date() # type: ignore
|
||||
assert recipe.last_made.date() == datetime.now(UTC).date() # type: ignore
|
||||
|
||||
# make sure nothing else was updated
|
||||
for data in [original_recipe_data, new_recipe_data]:
|
||||
|
@ -101,10 +101,10 @@ def test_new_mealplan_event_duplicates(api_client: TestClient, unique_user: Test
|
|||
response_json = response.json()
|
||||
initial_event_count = len(response_json["items"])
|
||||
|
||||
new_plan = CreatePlanEntry(
|
||||
date=datetime.now(timezone.utc).date(), entry_type="dinner", recipe_id=recipe_id
|
||||
).model_dump(by_alias=True)
|
||||
new_plan["date"] = datetime.now(timezone.utc).date().isoformat()
|
||||
new_plan = CreatePlanEntry(date=datetime.now(UTC).date(), entry_type="dinner", recipe_id=recipe_id).model_dump(
|
||||
by_alias=True
|
||||
)
|
||||
new_plan["date"] = datetime.now(UTC).date().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
response = api_client.post(api_routes.households_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
@ -148,9 +148,9 @@ def test_new_mealplan_events_with_multiple_recipes(api_client: TestClient, uniqu
|
|||
mealplan_count_by_recipe_id[recipe.id] = 0 # type: ignore
|
||||
for _ in range(random_int(1, 5)):
|
||||
new_plan = CreatePlanEntry(
|
||||
date=datetime.now(timezone.utc).date(), entry_type="dinner", recipe_id=str(recipe.id)
|
||||
date=datetime.now(UTC).date(), entry_type="dinner", recipe_id=str(recipe.id)
|
||||
).model_dump(by_alias=True)
|
||||
new_plan["date"] = datetime.now(timezone.utc).date().isoformat()
|
||||
new_plan["date"] = datetime.now(UTC).date().isoformat()
|
||||
new_plan["recipeId"] = str(recipe.id)
|
||||
|
||||
response = api_client.post(api_routes.households_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
@ -200,17 +200,17 @@ def test_preserve_future_made_date(api_client: TestClient, unique_user: TestUser
|
|||
recipe = RecipeSummary.model_validate(response.json())
|
||||
recipe_id = str(recipe.id)
|
||||
|
||||
future_dt = datetime.now(timezone.utc) + timedelta(days=random_int(1, 10))
|
||||
future_dt = datetime.now(UTC) + timedelta(days=random_int(1, 10))
|
||||
recipe.last_made = future_dt
|
||||
response = api_client.put(
|
||||
api_routes.recipes_slug(recipe.slug), json=utils.jsonify(recipe), headers=unique_user.token
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
new_plan = CreatePlanEntry(
|
||||
date=datetime.now(timezone.utc).date(), entry_type="dinner", recipe_id=recipe_id
|
||||
).model_dump(by_alias=True)
|
||||
new_plan["date"] = datetime.now(timezone.utc).date().isoformat()
|
||||
new_plan = CreatePlanEntry(date=datetime.now(UTC).date(), entry_type="dinner", recipe_id=recipe_id).model_dump(
|
||||
by_alias=True
|
||||
)
|
||||
new_plan["date"] = datetime.now(UTC).date().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
response = api_client.post(api_routes.households_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime, timezone
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from mealie.schema.household.group_shopping_list import ShoppingListItemCreate, ShoppingListItemOut, ShoppingListSave
|
||||
from mealie.services.scheduler.tasks.delete_old_checked_shopping_list_items import (
|
||||
|
@ -44,7 +44,7 @@ def test_cleanup(unique_user: TestUser):
|
|||
for item in unchecked_items + checked_items:
|
||||
assert item in shopping_list.list_items
|
||||
|
||||
checked_items.sort(key=lambda x: x.updated_at or datetime.now(timezone.utc), reverse=True)
|
||||
checked_items.sort(key=lambda x: x.updated_at or datetime.now(UTC), reverse=True)
|
||||
expected_kept_items = unchecked_items + checked_items[:MAX_CHECKED_ITEMS]
|
||||
expected_deleted_items = checked_items[MAX_CHECKED_ITEMS:]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import UUID4
|
||||
|
@ -31,7 +31,7 @@ def webhook_factory(
|
|||
name=name or random_string(),
|
||||
url=url or random_string(),
|
||||
webhook_type=webhook_type,
|
||||
scheduled_time=scheduled_time.time() if scheduled_time else datetime.now(timezone.utc).time(),
|
||||
scheduled_time=scheduled_time.time() if scheduled_time else datetime.now(UTC).time(),
|
||||
group_id=group_id,
|
||||
household_id=household_id,
|
||||
)
|
||||
|
@ -45,7 +45,7 @@ def test_get_scheduled_webhooks_filter_query(unique_user: TestUser):
|
|||
database = unique_user.repos
|
||||
expected: list[SaveWebhook] = []
|
||||
|
||||
start = datetime.now(timezone.utc)
|
||||
start = datetime.now(UTC)
|
||||
|
||||
for _ in range(5):
|
||||
new_item = webhook_factory(
|
||||
|
@ -65,7 +65,7 @@ def test_get_scheduled_webhooks_filter_query(unique_user: TestUser):
|
|||
expected.append(new_item)
|
||||
|
||||
event_bus_listener = WebhookEventListener(UUID(unique_user.group_id), UUID(unique_user.household_id))
|
||||
results = event_bus_listener.get_scheduled_webhooks(start, datetime.now(timezone.utc) + timedelta(minutes=5))
|
||||
results = event_bus_listener.get_scheduled_webhooks(start, datetime.now(UTC) + timedelta(minutes=5))
|
||||
|
||||
assert len(results) == len(expected)
|
||||
|
||||
|
@ -85,8 +85,8 @@ def test_event_listener_get_meals_by_date_range(unique_user: TestUser):
|
|||
"""
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
start_date = datetime.now(timezone.utc) - timedelta(days=7)
|
||||
end_date = datetime.now(timezone.utc)
|
||||
start_date = datetime.now(UTC) - timedelta(days=7)
|
||||
end_date = datetime.now(UTC)
|
||||
|
||||
meal_1 = meal_repo.create(
|
||||
{
|
||||
|
@ -152,8 +152,8 @@ def test_event_listener_get_meals_by_date_range(unique_user: TestUser):
|
|||
def test_get_meals_by_date_range(unique_user: TestUser):
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
start_date = datetime.now(timezone.utc) - timedelta(days=7)
|
||||
end_date = datetime.now(timezone.utc)
|
||||
start_date = datetime.now(UTC) - timedelta(days=7)
|
||||
end_date = datetime.now(UTC)
|
||||
|
||||
meal_1 = meal_repo.create(
|
||||
{
|
||||
|
@ -210,8 +210,8 @@ def test_get_meals_by_date_range_no_meals(unique_user: TestUser):
|
|||
"""
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
start_date = datetime.now(timezone.utc) - timedelta(days=7)
|
||||
end_date = datetime.now(timezone.utc)
|
||||
start_date = datetime.now(UTC) - timedelta(days=7)
|
||||
end_date = datetime.now(UTC)
|
||||
|
||||
meals_in_range = meal_repo.get_meals_by_date_range(start_date, end_date)
|
||||
|
||||
|
@ -224,7 +224,7 @@ def test_get_meals_by_date_range_single_day(unique_user: TestUser):
|
|||
"""
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
single_day = datetime.now(timezone.utc)
|
||||
single_day = datetime.now(UTC)
|
||||
|
||||
meal_1 = meal_repo.create(
|
||||
{
|
||||
|
@ -255,12 +255,12 @@ def test_get_meals_by_date_range_no_overlap(unique_user: TestUser):
|
|||
"""
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
start_date = datetime.now(timezone.utc) + timedelta(days=1)
|
||||
end_date = datetime.now(timezone.utc) + timedelta(days=10)
|
||||
start_date = datetime.now(UTC) + timedelta(days=1)
|
||||
end_date = datetime.now(UTC) + timedelta(days=10)
|
||||
|
||||
meal_1 = meal_repo.create(
|
||||
{
|
||||
"date": datetime.now(timezone.utc) - timedelta(days=5),
|
||||
"date": datetime.now(UTC) - timedelta(days=5),
|
||||
"entry_type": "dinner",
|
||||
"title": "Meal Outside Range",
|
||||
"text": "This meal is outside the tested date range",
|
||||
|
@ -289,7 +289,7 @@ def test_get_meals_by_date_range_invalid_date_range(unique_user: TestUser):
|
|||
"""
|
||||
meal_repo = unique_user.repos.meals
|
||||
|
||||
start_date = datetime.now(timezone.utc)
|
||||
start_date = datetime.now(UTC)
|
||||
end_date = start_date - timedelta(days=1)
|
||||
|
||||
meals_in_range = meal_repo.get_meals_by_date_range(start_date, end_date)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -65,7 +65,7 @@ def test_lock_unlocker_user(unique_user: TestUser) -> None:
|
|||
assert not unlocked_user.is_locked
|
||||
|
||||
# Sanity check that the is_locked property is working
|
||||
user.locked_at = datetime.now(timezone.utc) - timedelta(days=2)
|
||||
user.locked_at = datetime.now(UTC) - timedelta(days=2)
|
||||
assert not user.is_locked
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ def test_reset_locked_users(unique_user: TestUser, use_task: bool) -> None:
|
|||
assert user.login_attemps == 5
|
||||
|
||||
# Test that the locked user is unlocked by reset
|
||||
user.locked_at = datetime.now(timezone.utc) - timedelta(days=2)
|
||||
user.locked_at = datetime.now(UTC) - timedelta(days=2)
|
||||
database.users.update(user.id, user)
|
||||
if use_task:
|
||||
unlocked = locked_user_reset()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue