-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
Hi,
I have added fastapi-sqlalchemy to my app and it runs well if I start from main.py, where
app.add_middleware(DBSessionMiddleware, db_url=settings.DATABASE_RUL)
is added.
Now I am trying to build router-level unit test, which uses client = TestClient(router) to create router level client. So it won't run the code in main. the test failed and reports:
@property
def session(self) -> Session:
"""Return an instance of Session local to the current async context."""
if _Session is None:
> raise SessionNotInitialisedError
E fastapi_sqlalchemy.exceptions.SessionNotInitialisedError:
E Session not initialised! Ensure that DBSessionMiddleware has been initialised before
E attempting database access.
Any suggestion to use it in router level unit test?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels