[16.0][FIX] auditlog: Ensure unit tests unpatch methods. - #3364
Conversation
|
@AungKoKoLin1997 Would you kindly review this pull request? It fixes #3224. |
AungKoKoLin1997
left a comment
There was a problem hiding this comment.
How about like this?
This can reduce multiple lines.
7685850 to
0fc48d8
Compare
0fc48d8 to
9146bed
Compare
StefanRijnhart
left a comment
There was a problem hiding this comment.
This code looks like a welcome improvement to have auditlog tests clean up properly afterwards. But apart from that, is it not the case that the multicompany issue will still persist? Even though it is not triggered in the UI, will it still pop up when records are written in code?
Though #3224 describes itself as a multi-company issue, standard Odoo demo data installed for testing already has multiple companies. I perceive it as a test environment contamination problem, not a multi-company problem. The |
|
Picked into #3371 to fix the tests. There, the problem was indeed not the multi-company aspect fixed in the same PR but the fact that the patched methods mask method overrides loaded after the patching. |
9146bed to
e7c8308
Compare
Though TransactionCase rolls back database changes, it does not call `unlink` on `auditlog.rule` records, meaning that `unsubscribe` is never called to unpatch model methods. This causes subsequent tests in other modules to unexpectedly execute patched methods. This commit adds the `AuditLogRuleCommon` test class in an attempt to identify and prevent patched methods from contaminating the test environment.
e7c8308 to
8c2a4d1
Compare
StefanRijnhart
left a comment
There was a problem hiding this comment.
Thanks for the update!
/ocabot merge patch
|
What a great day to merge this nice PR. Let's do it! |
|
Congratulations, your PR was merged at d0d5875. Thanks a lot for contributing to OCA. ❤️ |
Though TransactionCase rolls back database changes, it does not call
unlinkonauditlog.rulerecords, meaning thatunsubscribeis never called to unpatch model methods. This causes subsequent tests in other modules to unexpectedly execute patched methods.This commit adds the
AuditLogRuleCommontest class in an attempt to identify and prevent patched methods from contaminating the test environment.