Test Constants
Relevant source files
The following files were used as context for generating this wiki page:
The Test Constants system in flext-tap-oracle provides a centralized and structured repository of static values, configuration defaults, and environment variable mappings used across the testing suite. This system ensures consistency between unit tests, integration tests, and end-to-end (E2E) scenarios by inheriting from production constants while extending them with test-specific overrides.
Architecturally, the test constants are organized within the TestsFlextTapOracleConstants class, which utilizes a nested class structure to categorize values by domain, such as container configuration, environment variable names, and unit test defaults. This structure is integrated into the broader testing framework through lazy loading and composition patterns.
Sources: tests/constants.py:12-20, tests/init.py:32-35
Core Architecture and Inheritance
The test constants follow a strict inheritance and composition model. The primary class, TestsFlextTapOracleConstants (aliased as c for brevity), inherits from both FlextTestsConstants and the production FlextTapOracleConstants. This allows the test suite to access production-level defaults while providing a specific namespace, TapOracle.Tests, for values exclusive to the testing environment.
The diagram shows the inheritance from external and production constant bases into the test constant facade.
Sources: tests/constants.py:20-24, tests/init.py:75-78
Test Configuration Categories
Shared Container Constants
These constants define the parameters for the Docker-based Oracle database used in integration and E2E tests. They include networking details, credentials, and service names required to establish a connection to the flext-oracle-db-test container.
| Constant Name | Type | Value | Description |
|---|---|---|---|
SHARED_CONTAINER_NAME | str | "flext-oracle-db-test" | Name of the Docker container. |
SHARED_CONTAINER_HOST | str | "localhost" | Host address for the test database. |
SHARED_CONTAINER_DEFAULT_PORT | int | 1522 | Fallback port if dynamic resolution fails. |
SHARED_CONTAINER_USER | str | "flext_test" | Database username for testing. |
SHARED_CONTAINER_SERVICE_NAME | str | "FLEXTDB" | Oracle Service Name for the test DB. |
Sources: tests/constants.py:28-36, tests/unit/fixtures.py:38-42
Environment Variable Mappings
The project uses specific environment variable keys to drive configuration. The constants system maps these keys to static strings, ensuring that environment overrides in pytest fixtures remain synchronized with the expected settings in FlextTapOracleSettings.
- Prefix System: The standard environment prefix is
FLEXT_TAP_ORACLE_. - Infrastructure Keys:
ORACLE_HOST,ORACLE_PORT,ORACLE_USERNAME,ORACLE_PASSWORD. - Framework Keys:
FLEXT_ENV,FLEXT_LOG_LEVEL,ORACLE_TAP_TEST_MODE.
Sources: tests/constants.py:37-55, src/flext_tap_oracle/settings.py:31-33, src/flext_tap_oracle/rules.json:52-54
Unit Test Defaults
For isolated unit tests that do not require a live database, the system provides a set of UNIT_ prefixed constants. These are used to create mock configurations and validate business logic without external dependencies.
UNIT_ORACLE_HOST: Final[str] = "test-oracle"
UNIT_ORACLE_PORT: Final[int] = 1521
UNIT_ORACLE_SERVICE_NAME: Final[str] = "TESTDB"
UNIT_ORACLE_USER: Final[str] = "testuser"
UNIT_ORACLE_PASSWORD: Final[str] = "testpass"
UNIT_BATCH_SIZE: Final[int] = 1000
Sources: tests/constants.py:59-64
Integration with Fixtures and Utilities
The constants are consumed by the testing infrastructure to manage the lifecycle of the test environment. Pytest fixtures in tests/unit/fixtures.py use these constants to setup and teardown environment variables and Docker containers.
The flow shows how constants provide the foundational data for environment configuration and mock object creation.
Sources: tests/unit/fixtures.py:100-112, tests/utilities.py:48-60
Validation Rules Context
While many constants are static strings, they are governed by validation constraints defined in the project's rules engine. For example, the batch_size constant (defaulting to 1000) must adhere to the minimum: 1 and maximum: 50000 constraints specified in the rules schema.
| Feature | Constraint Source | Value Range / Requirement |
|---|---|---|
batch_size | rules.json | 1 to 50,000 |
port | rules.json | 1 to 65,535 |
host/user/pass | settings.py | Required (Non-empty) |
Sources: src/flext_tap_oracle/rules.json:78-85, src/flext_tap_oracle/settings.py:65-70
Summary
The Test Constants system serves as the single source of truth for the flext-tap-oracle test suite. By centralizing infrastructure details like Docker container parameters and environment variable names, it enables a robust and maintainable testing environment that mirrors production configurations while allowing for the specific overrides necessary for comprehensive quality assurance.
Sources: tests/constants.py:7-10, README.md:55-58