This commit is contained in:
parent
ff66181768
commit
041ba14424
@ -5,6 +5,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
from database.database import Base, get_db_session # Keep get_db_session for dependency override
|
||||
from fastapi import FastAPI
|
||||
from database import database as db # Import the database module directly
|
||||
from jira_webhook_llm import create_app # Import create_app
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def setup_db(monkeypatch):
|
||||
@ -61,18 +62,11 @@ def mock_full_jira_payload(setup_db):
|
||||
@pytest.fixture(scope="function")
|
||||
def test_client(setup_db, monkeypatch):
|
||||
print("\n--- test_client fixture started ---")
|
||||
# Prevent signal handling and lifespan initialization in tests
|
||||
# Prevent signal handling in tests, but allow lifespan to run
|
||||
monkeypatch.setattr("jira_webhook_llm.handle_shutdown_signal", lambda *args: None)
|
||||
monkeypatch.setattr("jira_webhook_llm.lifespan", lambda app: None)
|
||||
|
||||
# Create a test app instance without lifespan
|
||||
app = FastAPI()
|
||||
|
||||
# Import and include routers manually
|
||||
from webhooks.handlers import webhook_router
|
||||
from api.handlers import router as api_router
|
||||
app.include_router(webhook_router)
|
||||
app.include_router(api_router)
|
||||
# Use the application factory to create the app instance with all middleware and routers
|
||||
app = create_app()
|
||||
|
||||
# Override the get_db_session dependency to use the test database
|
||||
# This will now correctly use the monkeypatched SessionLocal from database.database
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user