How to mock or override PermissionsDependency
Bulga-xD opened this issue · 0 comments
Bulga-xD commented
- FastAPI Contrib version: Latest
- FastAPI version: Latest
- Python version: 3.9.7
- Operating System: Mac Os
Description
Hello guys I need help with testing PermissionsDependency.
What I Did
My current code is :
api_router.include_router(
article_deviation.router,
prefix="{Confidential information}",
tags=["{confidential information}"],
dependencies=[
Depends(azure_scheme),
Depends(PermissionsDependency([QCPermission])),
],
)
In the test I override azure_scheme as :
api_client = TestClient(app)
app.dependency_overrides[azure_scheme] = {"Authorized": "Yes"}
but with
api_client = TestClient(app)
app.dependency_overrides[PermissionsDependency([QCPermission])] = True
It does not work.
Thank you in advance! Wish you all best!