[16.0][REF][l10n_br_base][l10n_br_fiscal][l10n_br_account] tests don't depend on demo #3563
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
both Odoo SA [1] and the OCA [2][3] recommend that tests don't depend on demo data. Here I'm starting this cleanup on the most central modules. Benefits include:
We have long wished to achieve that in the project. However, in l10n-brazil we need to maintain both complex fiscal demo data and fiscal test fixtures. That is why until now the test fiscal transactions where based on demo data.
In this PR, I created a simple framework (with l10n_br_base/tests/tools.py and l10n_br_fiscal/tests/tools.py) where we can load the SAME fiscal demo data both for the demo mode and for the tests even on databases created without demo data (like with the --without-demo=all param). I had to clean up a bit useless relations to demo data in the fiscal demo data and work around the demo data of the product module.
As we tend to reload the same fiscal demo fixtures in several tests, tests are a bit slower. But:
Finally, let me remind you that we cannot simply use the production set up for the Brazilian tax engine both for demo and tests because unlike for European countries, the Brazilian tax engine setup requires loading several MB of XML and csv files which easily take 3 minutes of heavy CPU usage and that would be a terrible developper experience to eat it for any quick test or CI push. (At the moment the decision to load production data or not happens in l10n_br_fiscal/hooks.py)
NOTE1: also see work in progress for l10n_br_sale module (some tests still failing) akretion@9667018 (in fact it seems my local test with --without-demo=all failed because of discrepancies between the demo and prod NCM data. See next note.
NOTE2: this PR will also work best in conjunction with the refactor of #3567 to standardize the data and demo files loading. Once #3567 is merged we will get rid of the demo NCM and CEST files so the load of the test fixtures will be much faster!