Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mock or override PermissionsDependency #186

Closed
Bulga-xD opened this issue Aug 10, 2022 · 0 comments
Closed

How to mock or override PermissionsDependency #186

Bulga-xD opened this issue Aug 10, 2022 · 0 comments

Comments

@Bulga-xD
Copy link

Bulga-xD commented Aug 10, 2022

  • 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant