Skip to content

Commit

Permalink
[FIX] fastapi: partner env for tests
Browse files Browse the repository at this point in the history
`partner` record leaks default env and even if you specify
`default_fastapi_running_user` to be custom user, when running tests,
running env will still have default (superuser), which makes testing
outcomes very different than you might expect.

Setting `partner` to use env with specified user, makes sure it won't
leak from there.
  • Loading branch information
oerp-odoo committed Dec 11, 2024
1 parent f89d54d commit 9112290
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fastapi/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def _create_test_client(
or self.default_fastapi_authenticated_partner
or self.env["res.partner"]
)
partner = partner.with_env(env)
if partner and authenticated_partner_impl in dependencies:
raise ValueError(
"You cannot provide an override for the authenticated_partner_impl "
Expand Down

0 comments on commit 9112290

Please sign in to comment.