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

[FIX] fastapi: allow test with no authenticated partner #373

Merged

Conversation

matthieusaison
Copy link

In case you need an anonymous call in your test.
The /fastapi/tests/common.py _create_test_client() function fails due to an empty authenticated_partner_impl.

This proposal allows you to define an empty partner for your test:
cls.default_fastapi_authenticated_partner = cls.env["res.partner"]

An authenticated test can be done like this:
self._create_test_client(partner=self.test_partner)

@OCA-git-bot
Copy link
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

@sebastienbeau
Copy link
Member

LGTM (code review), @lmignon ok for you ?

Copy link
Contributor

@lmignon lmignon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change to do is:

partner = partner or self.default_fastapi_authenticated_partner or self.env["res.partner"]
dependencies[authenticated_partner_impl] = partial(lambda a: a, partner)

@lmignon
Copy link
Contributor

lmignon commented Sep 22, 2023

ping @matthieusaison

@matthieusaison
Copy link
Author

Thanks @lmignon for your feedback, the change is made.

Copy link
Contributor

@lmignon lmignon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

@sebastienbeau
Copy link
Member

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-373-by-sebastienbeau-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit a8c4314 into OCA:16.0 Sep 25, 2023
5 of 6 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 4289428. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

4 participants