mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
* Added validators for users and recipes provide a simple get api, allowing to test for existence of - user by username - recipe by slug - group by name (not tested yet) * updated formatting * Use group_id+slug for recipes, use ValidationRespone * Fixed Flake8 errors and warnings * add missing field for TestUser init
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import requests
|
|
from pytest import fixture
|
|
from starlette.testclient import TestClient
|
|
|
|
from mealie.core.config import get_app_settings
|
|
from tests import utils
|
|
|
|
|
|
@fixture(scope="session")
|
|
def admin_token(api_client: requests, api_routes: utils.AppRoutes):
|
|
settings = get_app_settings()
|
|
|
|
form_data = {"username": "changeme@email.com", "password": settings.DEFAULT_PASSWORD}
|
|
return utils.login(form_data, api_client, api_routes)
|
|
|
|
|
|
@fixture(scope="session")
|
|
def admin_user(api_client: TestClient, api_routes: utils.AppRoutes):
|
|
settings = get_app_settings()
|
|
|
|
form_data = {"username": "changeme@email.com", "password": settings.DEFAULT_PASSWORD}
|
|
|
|
token = utils.login(form_data, api_client, api_routes)
|
|
|
|
user_data = api_client.get(api_routes.users_self, headers=token).json()
|
|
assert token is not None
|
|
|
|
assert user_data.get("admin") is True
|
|
assert user_data.get("groupId") is not None
|
|
assert user_data.get("id") is not None
|
|
|
|
try:
|
|
yield utils.TestUser(
|
|
_group_id=user_data.get("groupId"),
|
|
user_id=user_data.get("id"),
|
|
username=user_data.get("username"),
|
|
email=user_data.get("email"),
|
|
token=token,
|
|
)
|
|
finally:
|
|
# TODO: Delete User after test
|
|
pass
|