Skip to content
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

[16.0][REF][l10n_br_base][l10n_br_fiscal][l10n_br_account] tests don't depend on demo #3563

Draft
wants to merge 3 commits into
base: 16.0
Choose a base branch
from

Conversation

rvalyi
Copy link
Member

@rvalyi rvalyi commented Dec 28, 2024

both Odoo SA and the OCA recommend that tests don't depend on demo data. Here I'm starting this cleanup on the most central modules. Benefits include:

  • the test context is simpler and easier to figure out
  • this avoids the demo data incompatibility hell where arbitrary modules alter demo data and depending on what modules are installed exactly your tests may fail with no clear explanation
  • this allows to run fiscal tests on copy of production databases

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:

  • in the future they could actually be faster if we create test database with --without-demo=all
  • it's v16 which is 3x faster than v14, so not such a big deal (only a few dozens of extra seconds)
  • even if tests do a bit more queries, they are much easier and faster to debug this way...

@rvalyi rvalyi marked this pull request as draft December 28, 2024 02:45
@rvalyi rvalyi changed the title [REF] l10n_br_base: tests don't depend on demo [16.0][REF] l10n_br_base: tests don't depend on demo Dec 28, 2024
@rvalyi rvalyi changed the title [16.0][REF] l10n_br_base: tests don't depend on demo [16.0][REF][l10n_br_base][l10n_br_fiscal][l10n_br_account] tests don't depend on demo Dec 28, 2024
@rvalyi rvalyi force-pushed the 16.0-test-no-demo branch 5 times, most recently from 88cca3c to a2d95aa Compare December 28, 2024 03:24
@OCA-git-bot
Copy link
Contributor

Hi @renatonlima,
some modules you are maintaining are being modified, check this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants