-
Notifications
You must be signed in to change notification settings - Fork 30.6k
[IMP] account: assert or save XML test helpers #237861
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
Conversation
This commit adds helpers and improves on the way we assert XML files in `AccountTestInvoicingCommon` and all accounting test that extend from it. From now on, all accounting test code that assert an XML tree/string to an XML file should call the `assert_xml` helper, and design their test file name/location/etc. around this framework. This approach has a few major benefits: Assert / Save XML When testing XML files, we often need to perform create/read/update operations on the asserted XML to make sure it corresponds to the most updated/intended data. Previously, to save something to an XML, a developer would need to write their own local helpers to save the XML in the right directory. This was cumbersome and error-prone, so we decided to design a helper that allows developer to immediately save AND/OR update the asserted XML: to save/update an XML, we can simply add `SAVE_XML` as an additional test tags. Better test naming and optional subfolder management To better organize test files, the `assert_xml` method allows us to write just the test key name (without `.xml`), and the framework will automatically get the XML to assert/save from the `test_files` directory. An optional `subfolder` parameter is also added to allow writing to specific subfolder within `test_files`. Better `___ignore___` management in assertion XMLs Sometimes, we want to ignore a few XML node that are not relevant, or have content that are not deterministic (changes on every test run). To handle this, previously, developers would need to modify the assertion XML content by hand or write their own local script to do so. With this new framework, we just need to add an `ignore_schema.xml` file somewhere in the `test_files` directory. If put inside a subfolder, it will be applied with more priority towards the XML that are put on that specific subfolder. Save "pure" XML (before applying `___ignore___`) in temporary folder When calling `SAVE_XML`, before applying the ignore patches, the XML will be saved in a temporary folder (same folder as the screenshots for tours), so that developers can use them in external tests in the future, and for any other saving reasons. In addition, this commit also: - add `extra_tags` helper to save all the common tags for EDIs, for a better way to enable `EXTERNAL_MODE` testing inspired by `l10n_mx_edi` - convert some non-assert XML test helpers into a class method - canonicalize the XML to ensure consistency of the generated test files following the C14N Version 2 standard. (Deterministic namespaces location, sorted attributes, etc.) task-4891206 X-original-commit: 5fc84f1
|
This PR targets 19.0 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
|
@yosuanicolaus @smetl ci/runbot failed on this forward-port PR |
smetl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robodoo r+
|
@smetl you may want to rebuild or fix this PR as it has failed CI. |
|
@yosuanicolaus @smetl the next pull request (#238043) is in conflict. You can merge the chain up to here by saying
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |

This commit adds helpers and improves on the way we assert XML files in
AccountTestInvoicingCommonand all accounting test that extend from it. From now on, all accounting test code that assert an XML tree/string to an XML file should call theassert_xmlhelper, and design their test file name/location/etc. around this framework.This approach has a few major benefits:
Assert / Save XML
When testing XML files, we often need to perform create/read/update operations on the asserted XML to make sure it corresponds to the most updated/intended data. Previously, to save something to an XML, a developer would need to write their own local helpers to save the XML in the right directory. This was cumbersome and error-prone, so we decided to design a helper that allows developer to immediately save AND/OR update the asserted XML: to save/update an XML, we can simply add
SAVE_XMLas an additional test tags.Better test naming and optional subfolder management
To better organize test files, the
assert_xmlmethod allows us to write just the test key name (without.xml), and the framework will automatically get the XML to assert/save from thetest_filesdirectory. An optionalsubfolderparameter is also added to allow writing to specific subfolder withintest_files.Better
___ignore___management in assertion XMLsSometimes, we want to ignore a few XML node that are not relevant, or have content that are not deterministic (changes on every test run). To handle this, previously, developers would need to modify the assertion XML content by hand or write their own local script to do so.
With this new framework, we just need to add an
ignore_schema.xmlfile somewhere in thetest_filesdirectory. If put inside a subfolder, it will be applied with more priority towards the XML that are put on that specific subfolder.Save "pure" XML (before applying
___ignore___) in temporary folderWhen calling
SAVE_XML, before applying the ignore patches, the XML will be saved in a temporary folder (same folder as the screenshots for tours), so that developers can use them in external tests in the future, and for any other saving reasons.In addition, this commit also:
extra_tagshelper to save all the common tags for EDIs, for a better way to enableEXTERNAL_MODEtesting inspired byl10n_mx_editask-4891206
Forward-Port-Of: #237435
Forward-Port-Of: #237285