mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
* feat(backend): ✨ new meal-planner feature * feat(frontend): ✨ new meal plan feature * refactor(backend): ♻️ refactor base services classes and add mixins for crud * feat(frontend): ✨ add UI/API for mealplanner * feat(backend): ✨ add get_today and get_slice options for mealplanner * test(backend): ✅ add and update group mealplanner tests * fix(backend): 🐛 Fix recipe_id column type for PG Co-authored-by: hay-kot <hay-kot@pm.me>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class Routes:
|
|
base = "/api/groups/cookbooks"
|
|
|
|
def item(item_id: int) -> str:
|
|
return f"{Routes.base}/{item_id}"
|
|
|
|
|
|
@pytest.fixture()
|
|
def page_data():
|
|
return {"name": "My New Page", "description": "", "position": 0, "categories": [], "groupId": 1}
|
|
|
|
|
|
def test_create_cookbook(api_client: TestClient, admin_token, page_data):
|
|
response = api_client.post(Routes.base, json=page_data, headers=admin_token)
|
|
|
|
assert response.status_code == 201
|
|
|
|
|
|
def test_read_cookbook(api_client: TestClient, page_data, admin_token):
|
|
response = api_client.get(Routes.item(1), headers=admin_token)
|
|
|
|
page_data["id"] = 1
|
|
page_data["slug"] = "my-new-page"
|
|
|
|
assert response.json() == page_data
|
|
|
|
|
|
def test_update_cookbook(api_client: TestClient, page_data, admin_token):
|
|
page_data["id"] = 1
|
|
page_data["name"] = "My New Name"
|
|
response = api_client.put(Routes.item(1), json=page_data, headers=admin_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
def test_delete_cookbook(api_client: TestClient, admin_token):
|
|
response = api_client.delete(Routes.item(1), headers=admin_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
response = api_client.get(Routes.item(1), headers=admin_token)
|
|
assert response.status_code == 404
|