mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-02-27 04:17:23 -08:00
* change ALLOW_SIGNUP to default to false * add 1.4.0 tag for OIDC docs * new notes on security inline with security/policy review * safer transport for external requests * fix linter errors * docs: Tidy up wording/formatting * fix request errors * whoops * fix implementation with std lib * format * Remove check on netloc_parts. It only includes URL after any @ --------- Co-authored-by: boc-the-git <3479092+boc-the-git@users.noreply.github.com> Co-authored-by: Brendan <b.oconnell14@gmail.com>
64 lines
1.5 KiB
Python
64 lines
1.5 KiB
Python
import contextlib
|
|
from collections.abc import Generator
|
|
|
|
from pytest import MonkeyPatch, fixture
|
|
|
|
mp = MonkeyPatch()
|
|
mp.setenv("PRODUCTION", "True")
|
|
mp.setenv("TESTING", "True")
|
|
mp.setenv("ALLOW_SIGNUP", "True")
|
|
from pathlib import Path
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
from mealie.app import app
|
|
from mealie.core import config
|
|
from mealie.db.db_setup import SessionLocal, generate_session
|
|
from mealie.db.init_db import main
|
|
from tests import data as test_data
|
|
from tests.fixtures import * # noqa: F403 F401
|
|
|
|
main()
|
|
|
|
|
|
def override_get_db():
|
|
try:
|
|
db = SessionLocal()
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
|
|
@fixture(scope="session")
|
|
def api_client():
|
|
app.dependency_overrides[generate_session] = override_get_db
|
|
|
|
yield TestClient(app)
|
|
|
|
with contextlib.suppress(Exception):
|
|
settings = config.get_app_settings()
|
|
settings.DB_PROVIDER.db_path.unlink() # Handle SQLite Provider
|
|
|
|
|
|
@fixture(scope="session")
|
|
def test_image_jpg():
|
|
return test_data.images_test_image_1
|
|
|
|
|
|
@fixture(scope="session")
|
|
def test_image_png():
|
|
return test_data.images_test_image_2
|
|
|
|
|
|
@fixture(scope="session", autouse=True)
|
|
def global_cleanup() -> Generator[None, None, None]:
|
|
"""Purges the .temp directory used for testing"""
|
|
yield None
|
|
with contextlib.suppress(Exception):
|
|
temp_dir = Path(__file__).parent / ".temp"
|
|
|
|
if temp_dir.exists():
|
|
import shutil
|
|
|
|
shutil.rmtree(temp_dir, ignore_errors=True)
|