[IMP] merge TransactionCase and SavepointCase#62031
[IMP] merge TransactionCase and SavepointCase#62031rco-odoo wants to merge 9 commits intoodoo:masterfrom
Conversation
|
This is cool! 🎸 Are we supposed to have one of them be the "deprecated" flavor? I mean it because the code seems like the "ugly" kid is |
|
Great initiative!
Yeah that would be nice: keep SavepointCase class for a while and just deprecate it. It will help to not make all test suite break at once. |
d-fence
left a comment
There was a problem hiding this comment.
LGTM (as far as I can allow myself to review)
Maybe we should adapt the docstrings accordingly to document the merged savepointcase behavior ?
Julien00859
left a comment
There was a problem hiding this comment.
Hello @rco-odoo, is there static sphinx pages in the documentation we should also update or is it all generated from docstrings ?
55a373f to
04070fa
Compare
e2d7302 to
034487b
Compare
|
@Julien00859 I added the deprecation warning. |
The now unique class behaves as the former class `SavepointCase`. It is now up to the developer to use `setUp` or `setUpClass` for preparing the tests.
In unit tests, this avoids side effects from one test to another. In particular, a test modifying the user's company can make other tests fail because `env.company` defaults to the user's company when nothing else is available in the context.
Simply load translations in `setUpClass` instead of `setUp`.
As the same cursor is used by all tests, make sure to clear its `cache` upon setup.
As the test explicitly commits the cursor (this is necessary to release database locks), the teardown phase needs a valid savepoint.
One test method was setting `env.context` instead of creating a new environment.
034487b to
859a999
Compare
|
@robodoo rebase-ff r+ |
|
Merge method set to rebase and fast-forward |
closes #62031 Related: odoo/enterprise#14872 Signed-off-by: Raphael Collet (rco) <[email protected]>
|
Well, my suggestion was more to deprecate |
|
@rco-odoo @simahawk A good point should to improve common classes in order not to inherit from TransactionCase by default as it does not allow to inherit from it without launching all the test suites that inherit also. IMHO the AccountInvoicingCommon class should inherit from nothing as it is there to create data and so on. Only tests classes that have 'test_' functions should inherit from TransactionCase. |
|
Hi @rco-odoo I enriched the def action_signed(self) from the enterprise sign module for my customer. When I run my test I see that the system is unable to rollback what have been done in the test because of the commit inside de action_signed. I see in the sign tests the action_signed is not used. The workarround is a simple write state... Do you have an idea to get rid of it ? |
|
@tfossoul committing in the middle of a request is bad practice. You could try to avoid that commit by moving the subsequent action into a post-commit hook ( If you cannot remove that commit statement, then I see two other possible solutions:
|
|
@rco-odoo The "self.env.cr.commit()" line is part of odoo enterprise addons ;) I suspect the cr.commit is done before trying to send completed document by mail synchronously via the force_send option of _message_send_mail function |
Essentially make both classes be the same one, and behave like
SavepointCase.