mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
This PR does too many things :( 1. Major refactoring of the dev/scripts and dev/code-generation folders. Primarily this was removing duplicate code and cleaning up some poorly written code snippets as well as making them more idempotent so then can be re-run over and over again but still maintain the same results. This is working on my machine, but I've been having problems in CI and comparing diffs so running generators in CI will have to wait. 2. Re-Implement using the generated api routes for testing This was a _huge_ refactor that touched damn near every test file but now we have auto-generated typed routes with inline hints and it's used for nearly every test excluding a few that use classes for better parameterization. This should greatly reduce errors when writing new tests. 3. Minor Perf improvements for the All Recipes endpoint A. Removed redundant loops B. Uses orjson to do the encoding directly and returns a byte response instead of relying on the default jsonable_encoder. 4. Fix some TS type errors that cropped up for seemingly no reason half way through the PR. See this issue https://github.com/phillipdupuis/pydantic-to-typescript/issues/28 Basically, the generated TS type is not-correct since Pydantic will automatically fill in null fields. The resulting TS type is generated with a ? to indicate it can be null even though we _know_ that i can't be.
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from mealie.core.config import get_app_settings
|
|
from mealie.core.settings.static import APP_VERSION
|
|
from tests.utils import api_routes
|
|
from tests.utils.fixture_schemas import TestUser
|
|
|
|
|
|
def test_admin_about_get_app_info(api_client: TestClient, admin_user: TestUser):
|
|
response = api_client.get(api_routes.admin_about, headers=admin_user.token)
|
|
|
|
as_dict = response.json()
|
|
|
|
settings = get_app_settings()
|
|
|
|
assert as_dict["version"] == APP_VERSION
|
|
assert as_dict["demoStatus"] == settings.IS_DEMO
|
|
assert as_dict["apiPort"] == settings.API_PORT
|
|
assert as_dict["apiDocs"] == settings.API_DOCS
|
|
assert as_dict["dbType"] == settings.DB_ENGINE
|
|
# assert as_dict["dbUrl"] == settings.DB_URL_PUBLIC
|
|
assert as_dict["defaultGroup"] == settings.DEFAULT_GROUP
|
|
|
|
|
|
def test_admin_about_get_app_statistics(api_client: TestClient, admin_user: TestUser):
|
|
response = api_client.get(api_routes.admin_about_statistics, headers=admin_user.token)
|
|
|
|
as_dict = response.json()
|
|
|
|
# Smoke Test - Test the endpoint returns something that's a number
|
|
assert as_dict["totalRecipes"] >= 0
|
|
assert as_dict["uncategorizedRecipes"] >= 0
|
|
assert as_dict["untaggedRecipes"] >= 0
|
|
assert as_dict["totalUsers"] >= 0
|
|
assert as_dict["totalGroups"] >= 0
|
|
|
|
|
|
def test_admin_about_check_app_config(api_client: TestClient, admin_user: TestUser):
|
|
response = api_client.get(api_routes.admin_about_check, headers=admin_user.token)
|
|
|
|
as_dict = response.json()
|
|
|
|
# Smoke Test - Test the endpoint returns something that's a the expected shape
|
|
assert as_dict["emailReady"] in [True, False]
|
|
assert as_dict["ldapReady"] in [True, False]
|
|
assert as_dict["baseUrlSet"] in [True, False]
|
|
assert as_dict["isUpToDate"] in [True, False]
|