mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-03 04:25:24 +02:00
Feature/shopping lists second try (#927)
* generate types * use generated types * ui updates * init button link for common styles * add links * setup label views * add delete confirmation * reset when not saved * link label to foods and auto set when adding to shopping list * generate types * use inheritence to manage exception handling * fix schema generation and add test for open_api generation * add header to api docs * move list consilidation to service * split list and list items controller * shopping list/list item tests - PARTIAL * enable recipe add/remove in shopping lists * generate types * linting * init global utility components * update types and add list item api * fix import cycle and database error * add container and border classes * new recipe list component * fix tests * breakout item editor * refactor item editor * update bulk actions * update input / color contrast * type generation * refactor controller dependencies * include food/unit editor * remove console.logs * fix and update type generation * fix incorrect type for column * fix postgres error * fix delete by variable * auto remove refs * fix typo
This commit is contained in:
parent
f794208862
commit
92cf97e401
66 changed files with 2556 additions and 685 deletions
85
tests/fixtures/fixture_shopping_lists.py
vendored
Normal file
85
tests/fixtures/fixture_shopping_lists.py
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
import pytest
|
||||
import sqlalchemy
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.repos.repository_factory import AllRepositories
|
||||
from mealie.schema.group.group_shopping_list import ShoppingListItemCreate, ShoppingListOut, ShoppingListSave
|
||||
from tests.utils.factories import random_string
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
|
||||
|
||||
def create_item(list_id: UUID4) -> dict:
|
||||
return {
|
||||
"shopping_list_id": str(list_id),
|
||||
"checked": False,
|
||||
"position": 0,
|
||||
"is_food": False,
|
||||
"note": random_string(10),
|
||||
"quantity": 1,
|
||||
"unit_id": None,
|
||||
"unit": None,
|
||||
"food_id": None,
|
||||
"food": None,
|
||||
"recipe_id": None,
|
||||
"label_id": None,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def shopping_lists(database: AllRepositories, unique_user: TestUser):
|
||||
|
||||
models: list[ShoppingListOut] = []
|
||||
|
||||
for _ in range(3):
|
||||
model = database.group_shopping_lists.create(
|
||||
ShoppingListSave(name=random_string(10), group_id=unique_user.group_id),
|
||||
)
|
||||
|
||||
models.append(model)
|
||||
|
||||
yield models
|
||||
|
||||
for model in models:
|
||||
try:
|
||||
database.group_shopping_lists.delete(model.id)
|
||||
except Exception: # Entry Deleted in Test
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def shopping_list(database: AllRepositories, unique_user: TestUser):
|
||||
|
||||
model = database.group_shopping_lists.create(
|
||||
ShoppingListSave(name=random_string(10), group_id=unique_user.group_id),
|
||||
)
|
||||
|
||||
yield model
|
||||
|
||||
try:
|
||||
database.group_shopping_lists.delete(model.id)
|
||||
except Exception: # Entry Deleted in Test
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def list_with_items(database: AllRepositories, unique_user: TestUser):
|
||||
list_model = database.group_shopping_lists.create(
|
||||
ShoppingListSave(name=random_string(10), group_id=unique_user.group_id),
|
||||
)
|
||||
|
||||
for _ in range(10):
|
||||
database.group_shopping_list_item.create(
|
||||
ShoppingListItemCreate(
|
||||
**create_item(list_model.id),
|
||||
)
|
||||
)
|
||||
|
||||
# refresh model
|
||||
list_model = database.group_shopping_lists.get(list_model.id)
|
||||
|
||||
yield list_model
|
||||
|
||||
try:
|
||||
database.group_shopping_lists.delete(list_model.id)
|
||||
except sqlalchemy.exc.NoResultFound: # Entry Deleted in Test
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue