mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-03 04:25:24 +02:00
feat: Upgrade to Pydantic V2 (#3134)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
* bumped pydantic
This commit is contained in:
parent
248459671e
commit
7a107584c7
129 changed files with 1138 additions and 833 deletions
4
tests/fixtures/fixture_users.py
vendored
4
tests/fixtures/fixture_users.py
vendored
|
@ -16,7 +16,7 @@ def build_unique_user(group: str, api_client: TestClient) -> utils.TestUser:
|
|||
group = group or random_string(12)
|
||||
|
||||
registration = utils.user_registration_factory()
|
||||
response = api_client.post("/api/users/register", json=registration.dict(by_alias=True))
|
||||
response = api_client.post("/api/users/register", json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 201
|
||||
|
||||
form_data = {"username": registration.username, "password": registration.password}
|
||||
|
@ -84,7 +84,7 @@ def g2_user(admin_token, api_client: TestClient):
|
|||
@fixture(scope="module")
|
||||
def unique_user(api_client: TestClient):
|
||||
registration = utils.user_registration_factory()
|
||||
response = api_client.post("/api/users/register", json=registration.dict(by_alias=True))
|
||||
response = api_client.post("/api/users/register", json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 201
|
||||
|
||||
form_data = {"username": registration.username, "password": registration.password}
|
||||
|
|
|
@ -112,7 +112,7 @@ def test_get_all_public_recipes_filtered(
|
|||
|
||||
assert random_recipe.settings
|
||||
random_recipe.settings.public = True
|
||||
database.recipes.update(random_recipe.slug, random_recipe.dict() | recipe_data)
|
||||
database.recipes.update(random_recipe.slug, random_recipe.model_dump() | recipe_data)
|
||||
|
||||
## Query All Recipes
|
||||
response = api_client.get(api_routes.explore_recipes_group_slug(group.slug), params={"queryFilter": query_filter})
|
||||
|
|
|
@ -41,7 +41,7 @@ def cookbooks(database: AllRepositories, unique_user: TestUser) -> list[TestCook
|
|||
for _ in range(3):
|
||||
cb = database.cookbooks.create(SaveCookBook(**get_page_data(unique_user.group_id)))
|
||||
data.append(cb)
|
||||
yield_data.append(TestCookbook(id=cb.id, slug=cb.slug, name=cb.name, data=cb.dict()))
|
||||
yield_data.append(TestCookbook(id=cb.id, slug=cb.slug, name=cb.name, data=cb.model_dump()))
|
||||
|
||||
yield yield_data
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ def register_user(api_client, invite):
|
|||
registration.group = ""
|
||||
registration.group_token = invite
|
||||
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
return registration, response
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def route_all_slice(page: int, perPage: int, start_date: str, end_date: str):
|
|||
def test_create_mealplan_no_recipe(api_client: TestClient, unique_user: TestUser):
|
||||
title = random_string(length=25)
|
||||
text = random_string(length=25)
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="breakfast", title=title, text=text).dict()
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="breakfast", title=title, text=text).model_dump()
|
||||
new_plan["date"] = date.today().strftime("%Y-%m-%d")
|
||||
|
||||
response = api_client.post(api_routes.groups_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
@ -36,7 +36,7 @@ def test_create_mealplan_with_recipe(api_client: TestClient, unique_user: TestUs
|
|||
recipe = response.json()
|
||||
recipe_id = recipe["id"]
|
||||
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).dict(by_alias=True)
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).model_dump(by_alias=True)
|
||||
new_plan["date"] = date.today().strftime("%Y-%m-%d")
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
|
@ -53,7 +53,7 @@ def test_crud_mealplan(api_client: TestClient, unique_user: TestUser):
|
|||
entry_type="breakfast",
|
||||
title=random_string(),
|
||||
text=random_string(),
|
||||
).dict()
|
||||
).model_dump()
|
||||
|
||||
# Create
|
||||
new_plan["date"] = date.today().strftime("%Y-%m-%d")
|
||||
|
@ -91,7 +91,7 @@ def test_get_all_mealplans(api_client: TestClient, unique_user: TestUser):
|
|||
entry_type="breakfast",
|
||||
title=random_string(),
|
||||
text=random_string(),
|
||||
).dict()
|
||||
).model_dump()
|
||||
|
||||
new_plan["date"] = date.today().strftime("%Y-%m-%d")
|
||||
response = api_client.post(api_routes.groups_mealplans, json=new_plan, headers=unique_user.token)
|
||||
|
@ -109,7 +109,7 @@ def test_get_slice_mealplans(api_client: TestClient, unique_user: TestUser):
|
|||
|
||||
# Make a list of 10 meal plans
|
||||
meal_plans = [
|
||||
CreatePlanEntry(date=date, entry_type="breakfast", title=random_string(), text=random_string()).dict()
|
||||
CreatePlanEntry(date=date, entry_type="breakfast", title=random_string(), text=random_string()).model_dump()
|
||||
for date in dates
|
||||
]
|
||||
|
||||
|
@ -138,7 +138,9 @@ def test_get_slice_mealplans(api_client: TestClient, unique_user: TestUser):
|
|||
def test_get_mealplan_today(api_client: TestClient, unique_user: TestUser):
|
||||
# Create Meal Plans for today
|
||||
test_meal_plans = [
|
||||
CreatePlanEntry(date=date.today(), entry_type="breakfast", title=random_string(), text=random_string()).dict()
|
||||
CreatePlanEntry(
|
||||
date=date.today(), entry_type="breakfast", title=random_string(), text=random_string()
|
||||
).model_dump()
|
||||
for _ in range(3)
|
||||
]
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ def test_group_mealplan_rules_create(
|
|||
"groupId": unique_user.group_id,
|
||||
"day": "monday",
|
||||
"entryType": "breakfast",
|
||||
"categories": [category.dict()],
|
||||
"categories": [category.model_dump()],
|
||||
}
|
||||
|
||||
response = api_client.post(
|
||||
|
|
|
@ -38,14 +38,14 @@ def preferences_generator():
|
|||
category_created=random_bool(),
|
||||
category_updated=random_bool(),
|
||||
category_deleted=random_bool(),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
|
||||
def notifier_generator():
|
||||
return GroupEventNotifierCreate(
|
||||
name=random_string(),
|
||||
apprise_url=random_string(),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
|
||||
def event_generator():
|
||||
|
|
|
@ -33,7 +33,7 @@ def test_preferences_in_group(api_client: TestClient, unique_user: TestUser) ->
|
|||
def test_update_preferences(api_client: TestClient, unique_user: TestUser) -> None:
|
||||
new_data = UpdateGroupPreferences(recipe_public=False, recipe_show_nutrition=True)
|
||||
|
||||
response = api_client.put(api_routes.groups_preferences, json=new_data.dict(), headers=unique_user.token)
|
||||
response = api_client.put(api_routes.groups_preferences, json=new_data.model_dump(), headers=unique_user.token)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
@ -43,4 +43,4 @@ def test_update_preferences(api_client: TestClient, unique_user: TestUser) -> No
|
|||
assert preferences["recipePublic"] is False
|
||||
assert preferences["recipeShowNutrition"] is True
|
||||
|
||||
assert_ignore_keys(new_data.dict(by_alias=True), preferences, ["id", "groupId"])
|
||||
assert_ignore_keys(new_data.model_dump(by_alias=True), preferences, ["id", "groupId"])
|
||||
|
|
|
@ -7,7 +7,7 @@ from tests.utils.factories import user_registration_factory
|
|||
def test_user_registration_new_group(api_client: TestClient):
|
||||
registration = user_registration_factory()
|
||||
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 201
|
||||
|
||||
# Login
|
||||
|
@ -23,7 +23,7 @@ def test_user_registration_new_group(api_client: TestClient):
|
|||
def test_new_user_group_permissions(api_client: TestClient):
|
||||
registration = user_registration_factory()
|
||||
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 201
|
||||
|
||||
# Login
|
||||
|
|
|
@ -23,7 +23,7 @@ def create_item(list_id: UUID4) -> dict:
|
|||
def serialize_list_items(list_items: list[ShoppingListItemOut]) -> list:
|
||||
as_dict = []
|
||||
for item in list_items:
|
||||
item_dict = item.dict(by_alias=True)
|
||||
item_dict = item.model_dump(by_alias=True)
|
||||
item_dict["shoppingListId"] = str(item.shopping_list_id)
|
||||
item_dict["id"] = str(item.id)
|
||||
as_dict.append(item_dict)
|
||||
|
@ -192,7 +192,7 @@ def test_shopping_list_items_update_many_reorder(
|
|||
as_dict = []
|
||||
for i, item in enumerate(list_items):
|
||||
item.position = i
|
||||
item_dict = item.dict(by_alias=True)
|
||||
item_dict = item.model_dump(by_alias=True)
|
||||
item_dict["shoppingListId"] = str(list_with_items.id)
|
||||
item_dict["id"] = str(item.id)
|
||||
as_dict.append(item_dict)
|
||||
|
@ -319,7 +319,7 @@ def test_shopping_list_items_update_mergable(
|
|||
|
||||
item.note = list_with_items.list_items[i - 1].note
|
||||
|
||||
payload = utils.jsonify([item.dict() for item in list_with_items.list_items])
|
||||
payload = utils.jsonify([item.model_dump() for item in list_with_items.list_items])
|
||||
response = api_client.put(api_routes.groups_shopping_items, json=payload, headers=unique_user.token)
|
||||
as_json = utils.assert_derserialize(response, 200)
|
||||
|
||||
|
@ -382,7 +382,7 @@ def test_shopping_list_items_checked_off(
|
|||
|
||||
response = api_client.put(
|
||||
api_routes.groups_shopping_items_item_id(checked_item.id),
|
||||
json=utils.jsonify(checked_item.dict()),
|
||||
json=utils.jsonify(checked_item.model_dump()),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
|
||||
|
@ -396,7 +396,7 @@ def test_shopping_list_items_checked_off(
|
|||
# get the reference item and make sure it didn't change
|
||||
response = api_client.get(api_routes.groups_shopping_items_item_id(reference_item.id), headers=unique_user.token)
|
||||
as_json = utils.assert_derserialize(response, 200)
|
||||
reference_item_get = ShoppingListItemOut.parse_obj(as_json)
|
||||
reference_item_get = ShoppingListItemOut.model_validate(as_json)
|
||||
|
||||
assert reference_item_get.id == reference_item.id
|
||||
assert reference_item_get.shopping_list_id == reference_item.shopping_list_id
|
||||
|
@ -407,7 +407,7 @@ def test_shopping_list_items_checked_off(
|
|||
# rename an item to match another item and check both off, and make sure they are not merged
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(list_with_items.id), headers=unique_user.token)
|
||||
as_json = utils.assert_derserialize(response, 200)
|
||||
updated_list = ShoppingListOut.parse_obj(as_json)
|
||||
updated_list = ShoppingListOut.model_validate(as_json)
|
||||
|
||||
item_1, item_2 = random.sample(updated_list.list_items, 2)
|
||||
item_1.checked = True
|
||||
|
@ -416,7 +416,7 @@ def test_shopping_list_items_checked_off(
|
|||
|
||||
response = api_client.put(
|
||||
api_routes.groups_shopping_items,
|
||||
json=utils.jsonify([item_1.dict(), item_2.dict()]),
|
||||
json=utils.jsonify([item_1.model_dump(), item_2.model_dump()]),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
|
||||
|
|
|
@ -161,7 +161,9 @@ def test_shopping_lists_add_one_with_zero_quantity(
|
|||
response = api_client.put(f"{api_routes.recipes}/{recipe_slug}", json=recipe_data, headers=unique_user.token)
|
||||
utils.assert_derserialize(response, 200)
|
||||
|
||||
recipe = Recipe.parse_raw(api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content)
|
||||
recipe = Recipe.model_validate_json(
|
||||
api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content
|
||||
)
|
||||
assert recipe.id
|
||||
assert len(recipe.recipe_ingredient) == 3
|
||||
|
||||
|
@ -172,7 +174,7 @@ def test_shopping_lists_add_one_with_zero_quantity(
|
|||
)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(shopping_list.id), headers=unique_user.token)
|
||||
shopping_list_out = ShoppingListOut.parse_obj(utils.assert_derserialize(response, 200))
|
||||
shopping_list_out = ShoppingListOut.model_validate(utils.assert_derserialize(response, 200))
|
||||
|
||||
assert len(shopping_list_out.list_items) == 3
|
||||
|
||||
|
@ -285,7 +287,9 @@ def test_shopping_lists_add_recipe_with_merge(
|
|||
response = api_client.put(f"{api_routes.recipes}/{recipe_slug}", json=recipe_data, headers=unique_user.token)
|
||||
utils.assert_derserialize(response, 200)
|
||||
|
||||
recipe = Recipe.parse_raw(api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content)
|
||||
recipe = Recipe.model_validate_json(
|
||||
api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content
|
||||
)
|
||||
assert recipe.id
|
||||
assert len(recipe.recipe_ingredient) == 4
|
||||
|
||||
|
@ -296,7 +300,7 @@ def test_shopping_lists_add_recipe_with_merge(
|
|||
)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(shopping_list.id), headers=unique_user.token)
|
||||
shopping_list_out = ShoppingListOut.parse_obj(utils.assert_derserialize(response, 200))
|
||||
shopping_list_out = ShoppingListOut.model_validate(utils.assert_derserialize(response, 200))
|
||||
|
||||
assert len(shopping_list_out.list_items) == 3
|
||||
|
||||
|
@ -635,7 +639,9 @@ def test_recipe_manipulation_with_zero_quantities(
|
|||
response = api_client.put(f"{api_routes.recipes}/{recipe_slug}", json=recipe_data, headers=unique_user.token)
|
||||
utils.assert_derserialize(response, 200)
|
||||
|
||||
recipe = Recipe.parse_raw(api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content)
|
||||
recipe = Recipe.model_validate_json(
|
||||
api_client.get(f"{api_routes.recipes}/{recipe_slug}", headers=unique_user.token).content
|
||||
)
|
||||
assert recipe.id
|
||||
assert len(recipe.recipe_ingredient) == 4
|
||||
|
||||
|
@ -653,7 +659,7 @@ def test_recipe_manipulation_with_zero_quantities(
|
|||
utils.assert_derserialize(response, 200)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(shopping_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_raw(response.content)
|
||||
updated_list = ShoppingListOut.model_validate_json(response.content)
|
||||
assert len(updated_list.list_items) == 4
|
||||
|
||||
found = False
|
||||
|
@ -679,7 +685,7 @@ def test_recipe_manipulation_with_zero_quantities(
|
|||
)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(shopping_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_raw(response.content)
|
||||
updated_list = ShoppingListOut.model_validate_json(response.content)
|
||||
assert len(updated_list.list_items) == 4
|
||||
|
||||
found = False
|
||||
|
@ -705,7 +711,7 @@ def test_recipe_manipulation_with_zero_quantities(
|
|||
)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(shopping_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_raw(response.content)
|
||||
updated_list = ShoppingListOut.model_validate_json(response.content)
|
||||
assert len(updated_list.list_items) == 0
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def create_labels(api_client: TestClient, unique_user: TestUser, count: int = 10
|
|||
labels: list[MultiPurposeLabelOut] = []
|
||||
for _ in range(count):
|
||||
response = api_client.post(api_routes.groups_labels, json={"name": random_string()}, headers=unique_user.token)
|
||||
labels.append(MultiPurposeLabelOut.parse_obj(response.json()))
|
||||
labels.append(MultiPurposeLabelOut.model_validate(response.json()))
|
||||
|
||||
return labels
|
||||
|
||||
|
@ -25,7 +25,7 @@ def test_new_list_creates_list_labels(api_client: TestClient, unique_user: TestU
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
|
||||
assert len(new_list.label_settings) == len(labels)
|
||||
label_settings_label_ids = [setting.label_id for setting in new_list.label_settings]
|
||||
|
@ -39,13 +39,13 @@ def test_new_label_creates_list_labels(api_client: TestClient, unique_user: Test
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
existing_label_settings = new_list.label_settings
|
||||
|
||||
# create more labels and make sure they were added to the list's label settings
|
||||
new_labels = create_labels(api_client, unique_user)
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(new_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
updated_label_settings = updated_list.label_settings
|
||||
assert len(updated_label_settings) == len(existing_label_settings) + len(new_labels)
|
||||
|
||||
|
@ -66,7 +66,7 @@ def test_seed_label_creates_list_labels(database: AllRepositories, api_client: T
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
existing_label_settings = new_list.label_settings
|
||||
|
||||
# seed labels and make sure they were added to the list's label settings
|
||||
|
@ -75,7 +75,7 @@ def test_seed_label_creates_list_labels(database: AllRepositories, api_client: T
|
|||
seeder.seed_labels("en-US")
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(new_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
updated_label_settings = updated_list.label_settings
|
||||
assert len(updated_label_settings) == len(existing_label_settings) + CREATED_LABELS
|
||||
|
||||
|
@ -89,14 +89,14 @@ def test_delete_label_deletes_list_labels(api_client: TestClient, unique_user: T
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
|
||||
existing_label_settings = new_list.label_settings
|
||||
label_to_delete = random.choice(new_labels)
|
||||
api_client.delete(api_routes.groups_labels_item_id(label_to_delete.id), headers=unique_user.token)
|
||||
|
||||
response = api_client.get(api_routes.groups_shopping_lists_item_id(new_list.id), headers=unique_user.token)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
assert len(updated_list.label_settings) == len(existing_label_settings) - 1
|
||||
|
||||
label_settings_label_ids = [setting.label_id for setting in updated_list.label_settings]
|
||||
|
@ -116,11 +116,11 @@ def test_update_list_doesnt_change_list_labels(api_client: TestClient, unique_us
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": original_name}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
assert new_list.name == original_name
|
||||
assert new_list.label_settings
|
||||
|
||||
updated_list_data = new_list.dict()
|
||||
updated_list_data = new_list.model_dump()
|
||||
updated_list_data.pop("created_at", None)
|
||||
updated_list_data.pop("update_at", None)
|
||||
|
||||
|
@ -132,7 +132,7 @@ def test_update_list_doesnt_change_list_labels(api_client: TestClient, unique_us
|
|||
json=jsonify(updated_list_data),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
assert updated_list.name == updated_name
|
||||
assert updated_list.label_settings == new_list.label_settings
|
||||
|
||||
|
@ -142,7 +142,7 @@ def test_update_list_labels(api_client: TestClient, unique_user: TestUser):
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
changed_setting = random.choice(new_list.label_settings)
|
||||
changed_setting.position = random_int(999, 9999)
|
||||
|
||||
|
@ -151,7 +151,7 @@ def test_update_list_labels(api_client: TestClient, unique_user: TestUser):
|
|||
json=jsonify(new_list.label_settings),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
|
||||
original_settings_by_id = {setting.id: setting for setting in new_list.label_settings}
|
||||
for setting in updated_list.label_settings:
|
||||
|
@ -170,7 +170,7 @@ def test_list_label_order(api_client: TestClient, unique_user: TestUser):
|
|||
response = api_client.post(
|
||||
api_routes.groups_shopping_lists, json={"name": random_string()}, headers=unique_user.token
|
||||
)
|
||||
new_list = ShoppingListOut.parse_obj(response.json())
|
||||
new_list = ShoppingListOut.model_validate(response.json())
|
||||
for i, setting in enumerate(new_list.label_settings):
|
||||
if not i:
|
||||
continue
|
||||
|
@ -183,7 +183,7 @@ def test_list_label_order(api_client: TestClient, unique_user: TestUser):
|
|||
json=jsonify(new_list.label_settings),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
updated_list = ShoppingListOut.parse_obj(response.json())
|
||||
updated_list = ShoppingListOut.model_validate(response.json())
|
||||
for i, setting in enumerate(updated_list.label_settings):
|
||||
if not i:
|
||||
continue
|
||||
|
|
|
@ -46,7 +46,7 @@ def test_bulk_tag_recipes(
|
|||
for _ in range(3):
|
||||
tag_name = random_string()
|
||||
tag = database.tags.create(TagSave(group_id=unique_user.group_id, name=tag_name))
|
||||
tags.append(tag.dict())
|
||||
tags.append(tag.model_dump())
|
||||
|
||||
payload = {"recipes": ten_slugs, "tags": tags}
|
||||
|
||||
|
@ -74,7 +74,7 @@ def test_bulk_categorize_recipes(
|
|||
for _ in range(3):
|
||||
cat_name = random_string()
|
||||
cat = database.categories.create(CategorySave(group_id=unique_user.group_id, name=cat_name))
|
||||
categories.append(cat.dict())
|
||||
categories.append(cat.model_dump())
|
||||
|
||||
payload = {"recipes": ten_slugs, "categories": categories}
|
||||
|
||||
|
|
|
@ -461,7 +461,7 @@ def test_read_update(
|
|||
|
||||
recipe["notes"] = test_notes
|
||||
|
||||
recipe["recipeCategory"] = [x.dict() for x in recipe_categories]
|
||||
recipe["recipeCategory"] = [x.model_dump() for x in recipe_categories]
|
||||
|
||||
response = api_client.put(recipe_url, json=utils.jsonify(recipe), headers=unique_user.token)
|
||||
|
||||
|
@ -625,7 +625,7 @@ def test_remove_notes(api_client: TestClient, unique_user: TestUser):
|
|||
assert response.status_code == 200
|
||||
|
||||
recipe = json.loads(response.text)
|
||||
recipe["notes"] = [RecipeNote(title=random_string(), text=random_string()).dict()]
|
||||
recipe["notes"] = [RecipeNote(title=random_string(), text=random_string()).model_dump()]
|
||||
response = api_client.put(recipe_url, json=recipe, headers=unique_user.token)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def food(api_client: TestClient, unique_user: TestUser) -> Generator[dict, None,
|
|||
data = CreateIngredientFood(
|
||||
name=random_string(10),
|
||||
description=random_string(10),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
response = api_client.post(api_routes.foods, json=data, headers=unique_user.token)
|
||||
|
||||
|
@ -30,7 +30,7 @@ def test_create_food(api_client: TestClient, unique_user: TestUser):
|
|||
data = CreateIngredientFood(
|
||||
name=random_string(10),
|
||||
description=random_string(10),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
response = api_client.post(api_routes.foods, json=data, headers=unique_user.token)
|
||||
assert response.status_code == 201
|
||||
|
|
|
@ -26,7 +26,7 @@ def test_associate_ingredient_with_step(api_client: TestClient, unique_user: Tes
|
|||
|
||||
response = api_client.put(
|
||||
api_routes.recipes_slug(recipe.slug),
|
||||
json=jsonify(recipe.dict()),
|
||||
json=jsonify(recipe.model_dump()),
|
||||
headers=unique_user.token,
|
||||
)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ def recipes(api_client: TestClient, unique_user: TestUser):
|
|||
response = api_client.get(f"{api_routes.recipes}/{slug}", headers=unique_user.token)
|
||||
assert response.status_code == 200
|
||||
|
||||
recipe = Recipe.parse_obj(response.json())
|
||||
recipe = Recipe.model_validate(response.json())
|
||||
recipes.append(recipe)
|
||||
|
||||
yield recipes
|
||||
|
@ -52,7 +52,7 @@ def test_create_timeline_event(api_client: TestClient, unique_user: TestUser, re
|
|||
)
|
||||
assert event_response.status_code == 201
|
||||
|
||||
event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert event.recipe_id == recipe.id
|
||||
assert str(event.user_id) == str(unique_user.user_id)
|
||||
|
||||
|
@ -77,13 +77,13 @@ def test_get_all_timeline_events(api_client: TestClient, unique_user: TestUser,
|
|||
event_response = api_client.post(
|
||||
api_routes.recipes_timeline_events, params=params, json=event_data, headers=unique_user.token
|
||||
)
|
||||
events.append(RecipeTimelineEventOut.parse_obj(event_response.json()))
|
||||
events.append(RecipeTimelineEventOut.model_validate(event_response.json()))
|
||||
|
||||
# check that we see them all
|
||||
params = {"page": 1, "perPage": -1}
|
||||
|
||||
events_response = api_client.get(api_routes.recipes_timeline_events, params=params, headers=unique_user.token)
|
||||
events_pagination = RecipeTimelineEventPagination.parse_obj(events_response.json())
|
||||
events_pagination = RecipeTimelineEventPagination.model_validate(events_response.json())
|
||||
|
||||
event_ids = [event.id for event in events]
|
||||
paginated_event_ids = [event.id for event in events_pagination.items]
|
||||
|
@ -109,13 +109,13 @@ def test_get_timeline_event(api_client: TestClient, unique_user: TestUser, recip
|
|||
json=new_event_data,
|
||||
headers=unique_user.token,
|
||||
)
|
||||
new_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
new_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
|
||||
# fetch the new event
|
||||
event_response = api_client.get(api_routes.recipes_timeline_events_item_id(new_event.id), headers=unique_user.token)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert event == new_event
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ def test_update_timeline_event(api_client: TestClient, unique_user: TestUser, re
|
|||
}
|
||||
|
||||
event_response = api_client.post(api_routes.recipes_timeline_events, json=new_event_data, headers=unique_user.token)
|
||||
new_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
new_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert new_event.subject == old_subject
|
||||
|
||||
# update the event
|
||||
|
@ -146,7 +146,7 @@ def test_update_timeline_event(api_client: TestClient, unique_user: TestUser, re
|
|||
)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
updated_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
updated_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert updated_event.id == new_event.id
|
||||
assert updated_event.subject == new_subject
|
||||
assert updated_event.timestamp == new_event.timestamp
|
||||
|
@ -164,7 +164,7 @@ def test_delete_timeline_event(api_client: TestClient, unique_user: TestUser, re
|
|||
}
|
||||
|
||||
event_response = api_client.post(api_routes.recipes_timeline_events, json=new_event_data, headers=unique_user.token)
|
||||
new_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
new_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
|
||||
# delete the event
|
||||
event_response = api_client.delete(
|
||||
|
@ -172,7 +172,7 @@ def test_delete_timeline_event(api_client: TestClient, unique_user: TestUser, re
|
|||
)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
deleted_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
deleted_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert deleted_event.id == new_event.id
|
||||
|
||||
# try to get the event
|
||||
|
@ -198,7 +198,7 @@ def test_timeline_event_message_alias(api_client: TestClient, unique_user: TestU
|
|||
json=new_event_data,
|
||||
headers=unique_user.token,
|
||||
)
|
||||
new_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
new_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert str(new_event.user_id) == new_event_data["userId"]
|
||||
assert str(new_event.event_type) == new_event_data["eventType"]
|
||||
assert new_event.message == new_event_data["eventMessage"]
|
||||
|
@ -207,7 +207,7 @@ def test_timeline_event_message_alias(api_client: TestClient, unique_user: TestU
|
|||
event_response = api_client.get(api_routes.recipes_timeline_events_item_id(new_event.id), headers=unique_user.token)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert event == new_event
|
||||
|
||||
# update the event message
|
||||
|
@ -222,7 +222,7 @@ def test_timeline_event_message_alias(api_client: TestClient, unique_user: TestU
|
|||
)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
updated_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
updated_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert updated_event.subject == new_subject
|
||||
assert updated_event.message == new_message
|
||||
|
||||
|
@ -241,7 +241,7 @@ def test_timeline_event_update_image(
|
|||
}
|
||||
|
||||
event_response = api_client.post(api_routes.recipes_timeline_events, json=new_event_data, headers=unique_user.token)
|
||||
new_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
new_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert new_event.image == TimelineEventImage.does_not_have_image.value
|
||||
|
||||
with open(test_image_jpg, "rb") as f:
|
||||
|
@ -253,7 +253,7 @@ def test_timeline_event_update_image(
|
|||
)
|
||||
r.raise_for_status()
|
||||
|
||||
update_image_response = UpdateImageResponse.parse_obj(r.json())
|
||||
update_image_response = UpdateImageResponse.model_validate(r.json())
|
||||
assert update_image_response.image == TimelineEventImage.has_image.value
|
||||
|
||||
event_response = api_client.get(
|
||||
|
@ -262,7 +262,7 @@ def test_timeline_event_update_image(
|
|||
)
|
||||
assert event_response.status_code == 200
|
||||
|
||||
updated_event = RecipeTimelineEventOut.parse_obj(event_response.json())
|
||||
updated_event = RecipeTimelineEventOut.model_validate(event_response.json())
|
||||
assert updated_event.subject == new_event.subject
|
||||
assert updated_event.message == new_event.message
|
||||
assert updated_event.timestamp == new_event.timestamp
|
||||
|
@ -274,7 +274,7 @@ def test_create_recipe_with_timeline_event(api_client: TestClient, unique_user:
|
|||
for recipe in recipes:
|
||||
params = {"queryFilter": f"recipe_id={recipe.id}"}
|
||||
events_response = api_client.get(api_routes.recipes_timeline_events, params=params, headers=unique_user.token)
|
||||
events_pagination = RecipeTimelineEventPagination.parse_obj(events_response.json())
|
||||
events_pagination = RecipeTimelineEventPagination.model_validate(events_response.json())
|
||||
assert events_pagination.items
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def unit(api_client: TestClient, unique_user: TestUser):
|
|||
fraction=random_bool(),
|
||||
abbreviation=f"{random_string(3)}.",
|
||||
use_abbreviation=random_bool(),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
response = api_client.post(api_routes.units, json=data, headers=unique_user.token)
|
||||
|
||||
|
@ -30,7 +30,7 @@ def test_create_unit(api_client: TestClient, unique_user: TestUser):
|
|||
data = CreateIngredientUnit(
|
||||
name=random_string(10),
|
||||
description=random_string(10),
|
||||
).dict(by_alias=True)
|
||||
).model_dump(by_alias=True)
|
||||
|
||||
response = api_client.post(api_routes.units, json=data, headers=unique_user.token)
|
||||
assert response.status_code == 201
|
||||
|
|
|
@ -2,6 +2,7 @@ import random
|
|||
import string
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from mealie.core.config import get_app_settings
|
||||
from tests.utils import api_routes
|
||||
from tests.utils.factories import user_registration_factory
|
||||
|
@ -14,21 +15,21 @@ def test_register_user(api_client: TestClient, monkeypatch):
|
|||
# signup disabled but valid request
|
||||
monkeypatch.setenv("ALLOW_SIGNUP", "False")
|
||||
get_app_settings.cache_clear()
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 403
|
||||
|
||||
# signup disabled, request includes non valid group token
|
||||
registration.group_token = "".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10)).strip()
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 400
|
||||
|
||||
# signup enabled but contains non valid group token
|
||||
monkeypatch.setenv("ALLOW_SIGNUP", "True")
|
||||
get_app_settings.cache_clear()
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 400
|
||||
|
||||
# signup enabled and valid request
|
||||
registration.group_token = None
|
||||
response = api_client.post(api_routes.users_register, json=registration.dict(by_alias=True))
|
||||
response = api_client.post(api_routes.users_register, json=registration.model_dump(by_alias=True))
|
||||
assert response.status_code == 201
|
||||
|
|
|
@ -135,14 +135,14 @@ def test_pagination_guides(database: AllRepositories, unique_user: TestUser):
|
|||
query = PaginationQuery(page=1, per_page=1)
|
||||
|
||||
first_page_of_results = foods_repo.page_all(query)
|
||||
first_page_of_results.set_pagination_guides(foods_route, query.dict())
|
||||
first_page_of_results.set_pagination_guides(foods_route, query.model_dump())
|
||||
assert first_page_of_results.next is not None
|
||||
assert first_page_of_results.previous is None
|
||||
|
||||
query = PaginationQuery(page=-1, per_page=1)
|
||||
|
||||
last_page_of_results = foods_repo.page_all(query)
|
||||
last_page_of_results.set_pagination_guides(foods_route, query.dict())
|
||||
last_page_of_results.set_pagination_guides(foods_route, query.model_dump())
|
||||
assert last_page_of_results.next is None
|
||||
assert last_page_of_results.previous is not None
|
||||
|
||||
|
@ -150,7 +150,7 @@ def test_pagination_guides(database: AllRepositories, unique_user: TestUser):
|
|||
query = PaginationQuery(page=random_page, per_page=1, filter_string="createdAt>2021-02-22")
|
||||
|
||||
random_page_of_results = foods_repo.page_all(query)
|
||||
random_page_of_results.set_pagination_guides(foods_route, query.dict())
|
||||
random_page_of_results.set_pagination_guides(foods_route, query.model_dump())
|
||||
|
||||
next_params: dict = dict(parse_qsl(urlsplit(random_page_of_results.next).query)) # type: ignore
|
||||
assert int(next_params["page"]) == random_page + 1
|
||||
|
@ -158,7 +158,7 @@ def test_pagination_guides(database: AllRepositories, unique_user: TestUser):
|
|||
prev_params: dict = dict(parse_qsl(urlsplit(random_page_of_results.previous).query)) # type: ignore
|
||||
assert int(prev_params["page"]) == random_page - 1
|
||||
|
||||
source_params = camelize(query.dict())
|
||||
source_params = camelize(query.model_dump())
|
||||
for source_param in source_params:
|
||||
assert source_param in next_params
|
||||
assert source_param in prev_params
|
||||
|
@ -835,7 +835,7 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
|
|||
)
|
||||
|
||||
for mealplan_to_create in [mealplan_today, mealplan_tomorrow]:
|
||||
data = mealplan_to_create.dict()
|
||||
data = mealplan_to_create.model_dump()
|
||||
data["date"] = data["date"].strftime("%Y-%m-%d")
|
||||
response = api_client.post(api_routes.groups_mealplans, json=data, headers=unique_user.token)
|
||||
assert response.status_code == 201
|
||||
|
|
|
@ -17,7 +17,7 @@ class TestModel2(MealieModel):
|
|||
def test_camelize_variables():
|
||||
model = TestModel(long_name="Hello", long_int=1, long_float=1.1)
|
||||
|
||||
as_dict = model.dict(by_alias=True)
|
||||
as_dict = model.model_dump(by_alias=True)
|
||||
|
||||
assert as_dict["longName"] == "Hello"
|
||||
assert as_dict["longInt"] == 1
|
||||
|
|
|
@ -24,7 +24,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)
|
||||
original_recipe_data: dict = response.json()
|
||||
recipe = RecipeSummary.parse_obj(original_recipe_data)
|
||||
recipe = RecipeSummary.model_validate(original_recipe_data)
|
||||
recipe_id = recipe.id
|
||||
assert recipe.last_made is None
|
||||
|
||||
|
@ -34,7 +34,7 @@ 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=date.today(), entry_type="dinner", recipe_id=recipe_id).dict(by_alias=True)
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).model_dump(by_alias=True)
|
||||
new_plan["date"] = date.today().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
|
@ -62,7 +62,7 @@ def test_new_mealplan_event(api_client: TestClient, unique_user: TestUser):
|
|||
# make sure the recipe's last made date was updated
|
||||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
new_recipe_data: dict = response.json()
|
||||
recipe = RecipeSummary.parse_obj(new_recipe_data)
|
||||
recipe = RecipeSummary.model_validate(new_recipe_data)
|
||||
assert recipe.last_made.date() == date.today() # type: ignore
|
||||
|
||||
# make sure nothing else was updated
|
||||
|
@ -90,7 +90,7 @@ def test_new_mealplan_event_duplicates(api_client: TestClient, unique_user: Test
|
|||
assert response.status_code == 201
|
||||
|
||||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
recipe = RecipeSummary.parse_obj(response.json())
|
||||
recipe = RecipeSummary.model_validate(response.json())
|
||||
recipe_id = recipe.id
|
||||
|
||||
# store the number of events, so we can compare later
|
||||
|
@ -99,7 +99,7 @@ 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=date.today(), entry_type="dinner", recipe_id=recipe_id).dict(by_alias=True)
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).model_dump(by_alias=True)
|
||||
new_plan["date"] = date.today().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
|
@ -130,7 +130,7 @@ def test_new_mealplan_events_with_multiple_recipes(api_client: TestClient, uniqu
|
|||
assert response.status_code == 201
|
||||
|
||||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
recipes.append(RecipeSummary.parse_obj(response.json()))
|
||||
recipes.append(RecipeSummary.model_validate(response.json()))
|
||||
|
||||
# store the number of events, so we can compare later
|
||||
params = {"queryFilter": f"recipe_id={recipes[0].id}"}
|
||||
|
@ -143,7 +143,7 @@ def test_new_mealplan_events_with_multiple_recipes(api_client: TestClient, uniqu
|
|||
for recipe in recipes:
|
||||
mealplan_count_by_recipe_id[recipe.id] = 0 # type: ignore
|
||||
for _ in range(random_int(1, 5)):
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=str(recipe.id)).dict(
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=str(recipe.id)).model_dump(
|
||||
by_alias=True
|
||||
)
|
||||
new_plan["date"] = date.today().isoformat()
|
||||
|
@ -193,7 +193,7 @@ def test_preserve_future_made_date(api_client: TestClient, unique_user: TestUser
|
|||
assert response.status_code == 201
|
||||
|
||||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
recipe = RecipeSummary.parse_obj(response.json())
|
||||
recipe = RecipeSummary.model_validate(response.json())
|
||||
recipe_id = str(recipe.id)
|
||||
|
||||
future_dt = datetime.now() + timedelta(days=random_int(1, 10))
|
||||
|
@ -203,7 +203,7 @@ def test_preserve_future_made_date(api_client: TestClient, unique_user: TestUser
|
|||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).dict(by_alias=True)
|
||||
new_plan = CreatePlanEntry(date=date.today(), entry_type="dinner", recipe_id=recipe_id).model_dump(by_alias=True)
|
||||
new_plan["date"] = date.today().isoformat()
|
||||
new_plan["recipeId"] = str(recipe_id)
|
||||
|
||||
|
@ -214,5 +214,5 @@ def test_preserve_future_made_date(api_client: TestClient, unique_user: TestUser
|
|||
create_mealplan_timeline_events()
|
||||
|
||||
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
|
||||
recipe = RecipeSummary.parse_obj(response.json())
|
||||
recipe = RecipeSummary.model_validate(response.json())
|
||||
assert recipe.last_made == future_dt
|
||||
|
|
|
@ -7,8 +7,8 @@ from tests.utils.alembic_reader import ALEMBIC_MIGRATIONS, import_file
|
|||
|
||||
class AlembicMigration(BaseModel):
|
||||
path: pathlib.Path
|
||||
revision: str | None
|
||||
down_revision: str | None
|
||||
revision: str | None = None
|
||||
down_revision: str | None = None
|
||||
|
||||
|
||||
def test_alembic_revisions_are_in_order() -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue