Skip to content

Conversation

@jtrobles-cdd
Copy link
Member

Refactor several test files for enum and constant classes to improve maintainability, consistency, and clarity. The main changes involve shifting from direct imports and usage of module-level constants/enums to storing them as class variables set up in setUpClass(), and enhancing the tests to check type consistency and equality for enum members.

Key improvements include:

  • Consistent use of setUpClass to initialize class variables for constants and enums.
  • Enhanced type and equality checks for enum members in test cases.
  • Refactoring tests to use class variables instead of direct imports or module references.

The most important changes are:

Test structure and setup improvements:

  • Refactored all test classes in test_dte_constants.py, test_rcv_constants.py, test_rtc_constants.py, and test_rut_constants.py to use setUpClass() and store constants/enums as class variables, promoting consistency and easier maintenance.

Enum and constant validation enhancements:

  • Updated enum tests to include checks for member value types (e.g., ensuring all values are of type int or str) and to verify that enum members are equal to their values or names where appropriate.
  • Improved tests for enums with integer values (like TipoDte and RcvTipoDocto) to confirm that enum members are also instances of int, and that casting their values to int yields the member itself.
  • For enums with string values, added checks to ensure that member values match their names.

Test code simplification:

  • Replaced repetitive direct constant access in test methods with class variables, simplifying test code and reducing import clutter.

Documentation and clarity:

  • Added docstrings and comments to clarify test purposes, such as in TipoDteCediblesTest for TIPO_DTE_CEDIBLES.

These changes collectively make the test suite more robust, readable, and maintainable.

Refactor several test files for enum and constant classes to improve
maintainability, consistency, and clarity. The main changes involve
shifting from direct imports and usage of module-level constants/enums
to storing them as class variables set up in `setUpClass()`, and enhancing
the tests to check type consistency and equality for enum members.

Key improvements include:

- Consistent use of `setUpClass` to initialize class variables for
  constants and enums.
- Enhanced type and equality checks for enum members in test cases.
- Refactoring tests to use class variables instead of direct imports or
  module references.

The most important changes are:

**Test structure and setup improvements:**

- Refactored all test classes in `test_dte_constants.py`,
  `test_rcv_constants.py`, `test_rtc_constants.py`, and
  `test_rut_constants.py` to use `setUpClass()` and store constants/enums
  as class variables, promoting consistency and easier maintenance.

**Enum and constant validation enhancements:**

- Updated enum tests to include checks for member value types
  (e.g., ensuring all values are of type `int` or `str`) and to verify
  that enum members are equal to their values or names where appropriate.
- Improved tests for enums with integer values
  (like `TipoDte` and `RcvTipoDocto`) to confirm that enum members are
  also instances of `int`, and that casting their values to `int` yields
  the member itself.
- For enums with string values, added checks to ensure that member values
  match their names.

**Test code simplification:**

- Replaced repetitive direct constant access in test methods with class
  variables, simplifying test code and reducing import clutter.

**Documentation and clarity:**

- Added docstrings and comments to clarify test purposes, such as in
  `TipoDteCediblesTest` for `TIPO_DTE_CEDIBLES`.

These changes collectively make the test suite more robust, readable,
and maintainable.
@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.87%. Comparing base (02ec70b) to head (494dac6).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #888   +/-   ##
========================================
  Coverage    88.87%   88.87%           
========================================
  Files           38       38           
  Lines         3505     3505           
  Branches       345      345           
========================================
  Hits          3115     3115           
  Misses         239      239           
  Partials       151      151           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

@jtrobles-cdd jtrobles-cdd merged commit 4efa7f6 into develop Sep 11, 2025
20 checks passed
@jtrobles-cdd jtrobles-cdd deleted the refactor-and-improve-constants-tests branch September 11, 2025 01:02
@svillegas-cdd svillegas-cdd mentioned this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants