mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-30 17:53:31 -04:00 
			
		
		
		
	* fix type errors on event bus * webhooks fields required for new implementation * db migration * wip: webhook query + tests and stub function * ignore type checker error * type and method cleanup * datetime and time utc validator * update testing code for utc scheduled time * fix file cmp function call * update version_number * add support for translating "time" objects when restoring backup * bump recipe-scrapers * use specific import syntax * generate frontend types * utilize names exports * use utc times * add task to scheduler * implement new scheduler functionality * stub for type annotation * implement meal-plan data getter * add experimental banner
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import contextlib
 | |
| from collections.abc import Generator
 | |
| 
 | |
| from pytest import MonkeyPatch, fixture
 | |
| 
 | |
| mp = MonkeyPatch()
 | |
| mp.setenv("PRODUCTION", "True")
 | |
| mp.setenv("TESTING", "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)
 |