mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-02 12:05:21 +02:00
Feature/user seedable foods (#1176)
* remove odd ingredients * UI Elements for food * update translated percentage * spek -> speck * generate types * seeder api endpoints + tests * implement foods seeder UI * localize some food strings
This commit is contained in:
parent
67178f9b74
commit
d6e2b4ab85
60 changed files with 478 additions and 172 deletions
|
@ -0,0 +1,56 @@
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from mealie.repos.repository_factory import AllRepositories
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
from tests.utils.routes import RoutesSeeders
|
||||
|
||||
|
||||
def test_seed_invalid_locale(api_client: TestClient, unique_user: TestUser):
|
||||
for route in [RoutesSeeders.foods, RoutesSeeders.labels, RoutesSeeders.units]:
|
||||
resp = api_client.post(route, json={"locale": "invalid"}, headers=unique_user.token)
|
||||
assert resp.status_code == 422
|
||||
|
||||
|
||||
def test_seed_foods(api_client: TestClient, unique_user: TestUser, database: AllRepositories):
|
||||
CREATED_FOODS = 220
|
||||
|
||||
# Check that the foods was created
|
||||
foods = database.ingredient_foods.by_group(unique_user.group_id).get_all()
|
||||
assert len(foods) == 0
|
||||
|
||||
resp = api_client.post(RoutesSeeders.foods, json={"locale": "en-US"}, headers=unique_user.token)
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Check that the foods was created
|
||||
foods = database.ingredient_foods.by_group(unique_user.group_id).get_all()
|
||||
assert len(foods) == CREATED_FOODS
|
||||
|
||||
|
||||
def test_seed_units(api_client: TestClient, unique_user: TestUser, database: AllRepositories):
|
||||
CREATED_UNITS = 20
|
||||
|
||||
# Check that the foods was created
|
||||
units = database.ingredient_units.by_group(unique_user.group_id).get_all()
|
||||
assert len(units) == 0
|
||||
|
||||
resp = api_client.post(RoutesSeeders.units, json={"locale": "en-US"}, headers=unique_user.token)
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Check that the foods was created
|
||||
units = database.ingredient_units.by_group(unique_user.group_id).get_all()
|
||||
assert len(units) == CREATED_UNITS
|
||||
|
||||
|
||||
def test_seed_labels(api_client: TestClient, unique_user: TestUser, database: AllRepositories):
|
||||
CREATED_LABELS = 21
|
||||
|
||||
# Check that the foods was created
|
||||
labels = database.group_multi_purpose_labels.by_group(unique_user.group_id).get_all()
|
||||
assert len(labels) == 0
|
||||
|
||||
resp = api_client.post(RoutesSeeders.labels, json={"locale": "en-US"}, headers=unique_user.token)
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Check that the foods was created
|
||||
labels = database.group_multi_purpose_labels.by_group(unique_user.group_id).get_all()
|
||||
assert len(labels) == CREATED_LABELS
|
Loading…
Add table
Add a link
Reference in a new issue