Component Level Unit Tests
Relevant source files
The following files were used as context for generating this wiki page:
- tests/base.py
- tests/constants.py
- tests/models.py
- tests/protocols.py
- tests/settings.py
- tests/typings.py
- tests/utilities.py
- tests/unit/test_basic.py
- tests/unit/test_connections.py
- tests/unit/test_module_governance.py
- tests/unit/_config_parts/connection.py
- tests/unit/_config_parts/construction.py
- tests/unit/_config_parts/validation.py
- AGENTS.md
Component level unit tests in the flext-dbt-oracle repository ensure the reliability and architectural integrity of the Oracle dbt adapter. These tests are strictly isolated, focusing on configuration logic, connection management, and module governance without requiring a live database connection unless specifically marked for integration.
The testing framework leverages pytest and specialized utility namespaces (u, c, m, t) to validate that settings remain consistent and that implementation changes do not violate the project's "Zero-Tolerance" engineering laws.
Sources: AGENTS.md:310-335, tests/unit/test_basic.py:10-25, tests/utilities.py:17-30
Testing Architecture and Governance
The project enforces strict module governance through automated unit tests. These checks ensure that the package structure adheres to specific design patterns, such as forbidding module-level loggers and top-level functions within package modules to maintain a clean object-oriented architecture.
Governance Logic Flow
The governance tests iterate through the package root, identifying modules and inspecting their top-level attributes for compliance.
Configuration and Settings Validation
A significant portion of the unit test suite is dedicated to FlextDbtOracleSettings, ensuring that configuration values are correctly parsed, validated, and transformed into internal formats.
Validation Rules
Tests cover various aspects of configuration life cycles:
- Construction: Ensuring default values are applied when optional fields are omitted.
- Validation: Confirming that invalid inputs (e.g., incorrect materialization types or protocol strings) trigger a
ValidationError. - Mapping: Validating the transformation of settings into Oracle-specific connection configurations.
| Test Category | Focus Area | Source File |
|---|---|---|
| Construction | Basic creation, optional fields, and default constants | construction.py |
| Connection | DSN generation, schema mapping, and performance settings | connection.py |
| Validation | Range checks, enum membership, and missing field defaults | validation.py |
Sources: tests/unit/_config_parts/construction.py:11-50, tests/unit/_config_parts/connection.py:13-60, tests/unit/_config_parts/validation.py:15-80
Connection String Generation
The logic for generating Oracle connection strings is validated against different database identifiers (Service Name vs. SID).
Core Component Integration
Unit tests also verify the presence and basic functionality of core adapter components, ensuring that internal models and utilities are correctly exported and initialized.
Key Implementation Classes
Tests validate the following classes and structures:
OracleConnectionConfig: Manages connection primitives, ports, and DSN formatting.OracleTableAdapter: Handles relation name generation and metadata extraction (e.g.,HR.EMPLOYEES).FlextDbtOracleSettings: The central source of truth for all adapter configurations.
Sources: tests/unit/test_connections.py:16-55, tests/unit/test_impl.py:12-35, tests/unit/test_basic.py:15-32
Import Hierarchy
The following sequence shows how tests verify that the module structure allows for importing components without requiring a full dbt runtime environment.
Sources: tests/unit/test_imports.py:15-28
Technical Requirements for Test Execution
The project utilizes a specific set of tools and rules defined in pyproject.toml and AGENTS.md:
- Pytest Markers: Components are often marked with
@pytest.mark.unitto distinguish them fromdockerorintegrationtests. - Coverage Goals: The configuration targets a
fail_under = 20threshold for initial coverage, as specified in the managed project settings. - SSOT (Single Source of Truth): Tests are forbidden from hardcoding values that should be derived from
config/*.yamlorsettings.
Sources: pyproject.toml:140-150, AGENTS.md:20-35, tests/unit/test_basic.py:30
Conclusion
Component level unit tests provide the first line of defense for the flext-dbt-oracle project by enforcing structural governance and validating the complex configuration logic required for Oracle database interactions. By maintaining strict isolation and following the "Zero-Tolerance" engineering laws, these tests ensure that configuration changes are validated by construction rather than side effects.