mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-02 20:15:24 +02:00
feat: Add Households to Mealie (#3970)
This commit is contained in:
parent
0c29cef17d
commit
eb170cc7e5
315 changed files with 6975 additions and 3577 deletions
|
@ -1,7 +1,10 @@
|
|||
from uuid import UUID
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.repos.repository_factory import AllRepositories
|
||||
from mealie.schema.recipe.recipe import Recipe
|
||||
from tests.utils import api_routes
|
||||
from tests.utils.factories import random_string
|
||||
|
@ -39,7 +42,7 @@ def test_create_comment(api_client: TestClient, unique_recipe: Recipe, unique_us
|
|||
|
||||
assert response_data["recipeId"] == str(unique_recipe.id)
|
||||
assert response_data["text"] == create_data["text"]
|
||||
assert response_data["userId"] == unique_user.user_id
|
||||
assert response_data["userId"] == str(unique_user.user_id)
|
||||
|
||||
# Check for Proper Association
|
||||
response = api_client.get(api_routes.recipes_slug_comments(unique_recipe.slug), headers=unique_user.token)
|
||||
|
@ -50,7 +53,7 @@ def test_create_comment(api_client: TestClient, unique_recipe: Recipe, unique_us
|
|||
assert len(response_data) == 1
|
||||
assert response_data[0]["recipeId"] == str(unique_recipe.id)
|
||||
assert response_data[0]["text"] == create_data["text"]
|
||||
assert response_data[0]["userId"] == unique_user.user_id
|
||||
assert response_data[0]["userId"] == str(unique_user.user_id)
|
||||
|
||||
|
||||
def test_update_comment(api_client: TestClient, unique_recipe: Recipe, unique_user: TestUser):
|
||||
|
@ -73,7 +76,7 @@ def test_update_comment(api_client: TestClient, unique_recipe: Recipe, unique_us
|
|||
|
||||
assert response_data["recipeId"] == str(unique_recipe.id)
|
||||
assert response_data["text"] == update_data["text"]
|
||||
assert response_data["userId"] == unique_user.user_id
|
||||
assert response_data["userId"] == str(unique_user.user_id)
|
||||
|
||||
|
||||
def test_delete_comment(api_client: TestClient, unique_recipe: Recipe, unique_user: TestUser):
|
||||
|
@ -93,7 +96,20 @@ def test_delete_comment(api_client: TestClient, unique_recipe: Recipe, unique_us
|
|||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_admin_can_delete(api_client: TestClient, unique_recipe: Recipe, unique_user: TestUser, admin_user: TestUser):
|
||||
def test_admin_can_delete(
|
||||
unfiltered_database: AllRepositories,
|
||||
api_client: TestClient,
|
||||
unique_recipe: Recipe,
|
||||
unique_user: TestUser,
|
||||
admin_user: TestUser,
|
||||
):
|
||||
# Make sure admin belongs to same group/household as user
|
||||
admin_data = unfiltered_database.users.get_one(admin_user.user_id)
|
||||
assert admin_data
|
||||
admin_data.group_id = UUID(unique_user.group_id)
|
||||
admin_data.household_id = UUID(unique_user.household_id)
|
||||
unfiltered_database.users.update(admin_user.user_id, admin_data)
|
||||
|
||||
# Create Comment
|
||||
create_data = random_comment(unique_recipe.id)
|
||||
response = api_client.post(api_routes.comments, json=create_data, headers=unique_user.token)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue