mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
fix: Make Mealie Timezone-Aware (#3847)
Co-authored-by: boc-the-git <3479092+boc-the-git@users.noreply.github.com>
This commit is contained in:
parent
17f9eef551
commit
d5f7a883df
69 changed files with 250 additions and 176 deletions
|
@ -1,7 +1,7 @@
|
|||
import random
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from random import randint
|
||||
from urllib.parse import parse_qsl, urlsplit
|
||||
|
||||
|
@ -233,7 +233,7 @@ def test_pagination_filter_null(database: AllRepositories, unique_user: TestUser
|
|||
user_id=unique_user.user_id,
|
||||
group_id=unique_user.group_id,
|
||||
name=random_string(),
|
||||
last_made=datetime.now(),
|
||||
last_made=datetime.now(timezone.utc),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -619,7 +619,7 @@ def test_pagination_filter_datetimes(
|
|||
def test_pagination_order_by_multiple(
|
||||
database: AllRepositories, unique_user: TestUser, order_direction: OrderDirection
|
||||
):
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.now(timezone.utc)
|
||||
|
||||
alphabet = ["a", "b", "c", "d", "e"]
|
||||
abbreviations = alphabet.copy()
|
||||
|
@ -681,7 +681,7 @@ def test_pagination_order_by_multiple_directions(
|
|||
order_by_str: str,
|
||||
order_direction: OrderDirection,
|
||||
):
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.now(timezone.utc)
|
||||
|
||||
alphabet = ["a", "b", "c", "d", "e"]
|
||||
abbreviations = alphabet.copy()
|
||||
|
@ -729,7 +729,7 @@ def test_pagination_order_by_multiple_directions(
|
|||
def test_pagination_order_by_nested_model(
|
||||
database: AllRepositories, unique_user: TestUser, order_direction: OrderDirection
|
||||
):
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.now(timezone.utc)
|
||||
|
||||
alphabet = ["a", "b", "c", "d", "e"]
|
||||
labels = database.group_multi_purpose_labels.create_many(
|
||||
|
@ -759,7 +759,7 @@ def test_pagination_order_by_nested_model(
|
|||
|
||||
|
||||
def test_pagination_order_by_doesnt_filter(database: AllRepositories, unique_user: TestUser):
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.now(timezone.utc)
|
||||
|
||||
label = database.group_multi_purpose_labels.create(
|
||||
MultiPurposeLabelSave(name=random_string(), group_id=unique_user.group_id)
|
||||
|
@ -805,7 +805,7 @@ def test_pagination_order_by_nulls(
|
|||
null_position: OrderByNullPosition,
|
||||
order_direction: OrderDirection,
|
||||
):
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.now(timezone.utc)
|
||||
|
||||
label = database.group_multi_purpose_labels.create(
|
||||
MultiPurposeLabelSave(name=random_string(), group_id=unique_user.group_id)
|
||||
|
@ -909,10 +909,11 @@ def test_pagination_shopping_list_items_with_labels(database: AllRepositories, u
|
|||
|
||||
|
||||
def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
|
||||
yesterday = date.today() - timedelta(days=1)
|
||||
today = date.today()
|
||||
tomorrow = date.today() + timedelta(days=1)
|
||||
day_after_tomorrow = date.today() + timedelta(days=2)
|
||||
today = datetime.now(timezone.utc).date()
|
||||
|
||||
yesterday = today - timedelta(days=1)
|
||||
tomorrow = today + timedelta(days=1)
|
||||
day_after_tomorrow = today + timedelta(days=2)
|
||||
|
||||
mealplan_today = CreatePlanEntry(date=today, entry_type="breakfast", title=random_string(), text=random_string())
|
||||
mealplan_tomorrow = CreatePlanEntry(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import cast
|
||||
from uuid import UUID
|
||||
|
||||
|
@ -298,12 +298,12 @@ def test_recipe_repo_pagination_by_categories(database: AllRepositories, unique_
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for i in range(5):
|
||||
pagination_query.pagination_seed = str(datetime.now())
|
||||
pagination_query.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(database.recipes.page_all(pagination_query, categories=[category_slug]).items)
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
||||
|
@ -391,12 +391,12 @@ def test_recipe_repo_pagination_by_tags(database: AllRepositories, unique_user:
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for i in range(5):
|
||||
pagination_query.pagination_seed = str(datetime.now())
|
||||
pagination_query.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(database.recipes.page_all(pagination_query, tags=[tag_slug]).items)
|
||||
assert len(random_ordered[0]) == 15
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
@ -487,12 +487,12 @@ def test_recipe_repo_pagination_by_tools(database: AllRepositories, unique_user:
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for i in range(5):
|
||||
pagination_query.pagination_seed = str(datetime.now())
|
||||
pagination_query.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(database.recipes.page_all(pagination_query, tools=[tool_id]).items)
|
||||
assert len(random_ordered[0]) == 15
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
@ -571,12 +571,12 @@ def test_recipe_repo_pagination_by_foods(database: AllRepositories, unique_user:
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for i in range(5):
|
||||
pagination_query.pagination_seed = str(datetime.now())
|
||||
pagination_query.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(database.recipes.page_all(pagination_query, foods=[food_id]).items)
|
||||
assert len(random_ordered[0]) == 15
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
@ -651,12 +651,12 @@ def test_random_order_recipe_search(
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for _ in range(5):
|
||||
pagination.pagination_seed = str(datetime.now())
|
||||
pagination.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(repo.page_all(pagination, search="soup").items)
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -125,11 +125,11 @@ def test_random_order_search(
|
|||
page=1,
|
||||
per_page=-1,
|
||||
order_by="random",
|
||||
pagination_seed=str(datetime.now()),
|
||||
pagination_seed=str(datetime.now(timezone.utc)),
|
||||
order_direction=OrderDirection.asc,
|
||||
)
|
||||
random_ordered = []
|
||||
for _ in range(5):
|
||||
pagination.pagination_seed = str(datetime.now())
|
||||
pagination.pagination_seed = str(datetime.now(timezone.utc))
|
||||
random_ordered.append(repo.page_all(pagination, search="unit").items)
|
||||
assert not all(i == random_ordered[0] for i in random_ordered)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue