mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-03 05:35:02 -04:00
* feat: ✨ Add Description to Cookbooks * feat(frontend): ✨ Cookbook view page * feat(frontend): 💄 Add final UI touches * fix(backend): 🐛 Add get by slug or id * fix linting issue * test(backend): ✅ Update tests from pages -> cookbooks * refactor(backend): 🔥 Delete old page files Co-authored-by: hay-kot <hay-kot@pm.me>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import json
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from tests.app_routes import AppRoutes
|
|
|
|
|
|
@pytest.fixture()
|
|
def page_data():
|
|
return {"name": "My New Page", "description": "", "position": 0, "categories": [], "groupId": 1}
|
|
|
|
|
|
def test_create_cookbook(api_client: TestClient, api_routes: AppRoutes, admin_token, page_data):
|
|
response = api_client.post(api_routes.group_cookbook, json=page_data, headers=admin_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
def test_read_cookbook(api_client: TestClient, api_routes: AppRoutes, page_data, admin_token):
|
|
response = api_client.get(api_routes.group_cookbook_id(1), headers=admin_token)
|
|
|
|
page_data["id"] = 1
|
|
page_data["slug"] = "my-new-page"
|
|
|
|
assert json.loads(response.text) == page_data
|
|
|
|
|
|
def test_update_cookbook(api_client: TestClient, api_routes: AppRoutes, page_data, admin_token):
|
|
page_data["id"] = 1
|
|
page_data["name"] = "My New Name"
|
|
response = api_client.put(api_routes.group_cookbook_id(1), json=page_data, headers=admin_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
def test_delete_cookbook(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
|
response = api_client.delete(api_routes.group_cookbook_id(1), headers=admin_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
response = api_client.get(api_routes.group_cookbook_id(1), headers=admin_token)
|
|
assert response.status_code == 404
|