Skip to content

Conversation

@rvalyi
Copy link
Member

@rvalyi rvalyi commented Jan 2, 2026

This PR refactors the tests for l10n_br_base, l10n_br_fiscal, and l10n_br_nfse to remove their dependency on the global Odoo demo data loading mechanism.

Context & Motivation

Historically, l10n-brazil tests relied on complex fiscal demo data. This created several issues:

  1. Incompatibility Hell: Arbitrary modules installed in a test environment could alter shared demo data, causing fragile and unexplained test failures.
  2. Production DB Testing: It was impossible to run fiscal tests on copies of production databases or databases initialized with --without-demo=all.
  3. Performance: Loading the full Brazilian tax engine production data for every test run is prohibitively slow (several minutes of XML/CSV loading).

This work follows the pattern I previously proposed for 16.0 in PR #3563 and aligns with Odoo SA and OCA guidelines to keep tests independent of demo data.

Implementation Details

I introduced a lightweight fixture loading framework (see l10n_br_base/tests/tools.py and l10n_br_fiscal/tests/tools.py) that allows tests to:

  • Load the same XML data files used for demo purposes, but explicitly within the setUpClass of the test transaction.
  • Create minimal "mock" records for required dependencies (like base.res_partner_1 or product.product_product_1) if they don't exist, preventing crashes on empty databases.
  • Avoid the heavy overhead of loading the full production tax setup for simple unit tests.

Benefits

  • Robustness: Tests are now self-contained and less likely to break due to unrelated module changes.
  • CI/CD Future-Proofing: This change is critical for upcoming Odoo versions (like 19.0) where the standard OCA CI pipeline defaults to not loading demo data. Implementing this in 18.0 significantly smooths the migration path.
  • Developer Experience: Developers can run these tests on any database state without needing a fresh demo-enabled DB every time.

Modules Covered

  • l10n_br_base
  • l10n_br_fiscal
  • l10n_br_nfse

Dependencies like l10n_br_fiscal_edi, l10n_br_fiscal_certificate, etc., do not rely on demo data and thus required no changes.

@OCA-git-bot
Copy link
Contributor

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

@rvalyi rvalyi changed the title [REF] l10n_br_base, l10n_br_fiscal, l10n_br_nfse: decouple tests from demo data [18.0][REF] l10n_br_base, l10n_br_fiscal, l10n_br_nfse: decouple tests from demo data Jan 2, 2026
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