mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
feature: proper multi-tenant-support (#969)(WIP)
* update naming * refactor tests to use shared structure * shorten names * add tools test case * refactor to support multi-tenant * set group_id on creation * initial refactor for multitenant tags/cats * spelling * additional test case for same valued resources * fix recipe update tests * apply indexes to foreign keys * fix performance regressions * handle unknown exception * utility decorator for function debugging * migrate recipe_id to UUID * GUID for recipes * remove unused import * move image functions into package * move utilities to packages dir * update import * linter * image image and asset routes * update assets and images to use UUIDs * fix migration base * image asset test coverage * use ids for categories and tag crud functions * refactor recipe organizer test suite to reduce duplication * add uuid serlization utility * organizer base router * slug routes testing and fixes * fix postgres error * adopt UUIDs * move tags, categories, and tools under "organizers" umbrella * update composite label * generate ts types * fix import error * update frontend types * fix type errors * fix postgres errors * fix #978 * add null check for title validation * add note in docs on multi-tenancy
This commit is contained in:
parent
9a82a172cb
commit
c617251f4c
157 changed files with 1866 additions and 1578 deletions
|
@ -10,8 +10,10 @@ from recipe_scrapers._abstract import AbstractScraper
|
|||
from recipe_scrapers._schemaorg import SchemaOrg
|
||||
from slugify import slugify
|
||||
|
||||
from mealie.services.scraper import scraper
|
||||
from mealie.schema.recipe.recipe import RecipeCategory
|
||||
from mealie.services.recipe.recipe_data_service import RecipeDataService
|
||||
from mealie.services.scraper.scraper_strategies import RecipeScraperOpenGraph
|
||||
from tests import utils
|
||||
from tests.utils.app_routes import AppRoutes
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
from tests.utils.recipe_data import RecipeSiteTestCase, get_recipe_test_cases
|
||||
|
@ -73,8 +75,8 @@ def test_create_by_url(
|
|||
)
|
||||
# Skip image downloader
|
||||
monkeypatch.setattr(
|
||||
scraper,
|
||||
"download_image_for_recipe",
|
||||
RecipeDataService,
|
||||
"scrape_image",
|
||||
lambda *_: "TEST_IMAGE",
|
||||
)
|
||||
|
||||
|
@ -88,7 +90,11 @@ def test_create_by_url(
|
|||
|
||||
@pytest.mark.parametrize("recipe_data", recipe_test_data)
|
||||
def test_read_update(
|
||||
api_client: TestClient, api_routes: AppRoutes, recipe_data: RecipeSiteTestCase, unique_user: TestUser
|
||||
api_client: TestClient,
|
||||
api_routes: AppRoutes,
|
||||
recipe_data: RecipeSiteTestCase,
|
||||
unique_user: TestUser,
|
||||
recipe_categories: list[RecipeCategory],
|
||||
):
|
||||
recipe_url = api_routes.recipes_recipe_slug(recipe_data.expected_slug)
|
||||
response = api_client.get(recipe_url, headers=unique_user.token)
|
||||
|
@ -103,14 +109,9 @@ def test_read_update(
|
|||
|
||||
recipe["notes"] = test_notes
|
||||
|
||||
test_categories = [
|
||||
{"name": "one", "slug": "one"},
|
||||
{"name": "two", "slug": "two"},
|
||||
{"name": "three", "slug": "three"},
|
||||
]
|
||||
recipe["recipeCategory"] = test_categories
|
||||
recipe["recipeCategory"] = [x.dict() for x in recipe_categories]
|
||||
|
||||
response = api_client.put(recipe_url, json=recipe, headers=unique_user.token)
|
||||
response = api_client.put(recipe_url, json=utils.jsonify(recipe), headers=unique_user.token)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.text).get("slug") == recipe_data.expected_slug
|
||||
|
@ -121,10 +122,10 @@ def test_read_update(
|
|||
|
||||
assert recipe["notes"] == test_notes
|
||||
|
||||
assert len(recipe["recipeCategory"]) == len(test_categories)
|
||||
assert len(recipe["recipeCategory"]) == len(recipe_categories)
|
||||
|
||||
test_name = [x["name"] for x in test_categories]
|
||||
for cats in zip(recipe["recipeCategory"], test_categories):
|
||||
test_name = [x.name for x in recipe_categories]
|
||||
for cats in zip(recipe["recipeCategory"], recipe_categories):
|
||||
assert cats[0]["name"] in test_name
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue