Uh oh!
There was an error while loading. Please reload this page.
[14.0] Fix trap_jobs() recordset comparison - #537
Conversation
The trap_jobs() test helper accepts any model/recordset as long
as the job function is the same, which is not enough to verify that
the job has been delayed on the expected recordset or model.
Tested job functions are "bound methods" so we can compare their `__self__`.
Example of assertion that would be valid:
partner = self.env["res.partner"].create({"name": "foo"})
with trap_jobs() as trap:
partner.with_delay().do_something(42)
trap.assert_jobs_count(1, only=self.env["res.partner"].do_something)
trap.assert_enqueued_job(
self.env["res.partner"].do_something,
args=(42,)
)
Now, it would fail with an error message like:
E AssertionError: Job <res.partner()>.do_something(42) with properties (channel=root.test, description=Do something, eta=15, identity_key=<function identity_exact at 0x7f01bfb54cb0>, max_retries=1, priority=15) was not enqueued.
E Actual enqueued jobs:
E * <res.partner(64,)>.do_something(42) with properties (priority=15, max_retries=1, eta=15, description=Do something, channel=root.test, identity_key=<function identity_exact at 0x7f01bfb54cb0>)OCA-git-bot
commented
May 14, 2023
This PR has the |
guewen
commented
Jun 2, 2023
/ocabot merge minor I choose minor over patch because succeeding tests can now fail (these tests were not "correct" in the first place), there is no breaking change otherwise. |
OCA-git-bot
commented
Jun 2, 2023
On my way to merge this fine PR! |
OCA-git-bot
commented
Jun 2, 2023
@guewen your merge command was aborted due to failed check(s), which you can inspect on this commit of 14.0-ocabot-merge-pr-537-by-guewen-bump-minor. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
guewen
commented
Jun 7, 2023
/ocabot merge minor |
OCA-git-bot
commented
Jun 7, 2023
This PR looks fantastic, let's merge it! |
OCA-git-bot
commented
Jun 7, 2023
@guewen your merge command was aborted due to failed check(s), which you can inspect on this commit of 14.0-ocabot-merge-pr-537-by-guewen-bump-minor. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
guewen
commented
Jun 7, 2023
Oh, it fails because of odoo/odoo@f0cab1b |
Added in odoo/odoo@f0cab1b This a partial backport of commit e74109f in 15.0 Co-authored-by: romi477 <romi4240101@gmail.com>
guewen
commented
Jun 7, 2023
/ocabot merge minor |
OCA-git-bot
commented
Jun 7, 2023
What a great day to merge this nice PR. Let's do it! |
OCA-git-bot
commented
Jun 7, 2023
Congratulations, your PR was merged at 03202fa. Thanks a lot for contributing to OCA. ❤️ |
The trap_jobs() test helper accepts any model/recordset as long as the job function is the same, which is not enough to verify that the job has been delayed on the expected recordset or model.
Tested job functions are "bound methods" so we can (and should) compare their
__self__.Example of assertion that would be valid:
Now, it would fail with an error message like: