Connection Implementation Tests
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Connection Implementation Tests verify the integrity and correctness of the Oracle database connection logic within the flext-dbt-oracle adapter. These tests ensure that configuration settings, connection string generation, and dbt-specific environment parameters are correctly mapped and validated before being utilized by the adapter's runtime. The scope includes validating credentials, connection identifiers (SID vs. Service Name), and performance-related pooling settings.
These tests serve as a quality gate to prevent regressions in how the adapter interacts with Oracle instances, adhering to the project's policy that tests must validate configuration changes by construction rather than hardcoding values.
Sources: AGENTS.md:12-25, tests/unit/test_config.py:12-20
Configuration and Settings Architecture
The configuration system is built around FlextDbtOracleSettings, which inherits from base Pydantic models to provide typed validation and conversion logic. The architecture separates raw connection parameters from performance and dbt-specific execution settings.
Core Settings Components
The configuration is decomposed into several functional areas:
- Connection Primitives: Host, port, username, password, and protocol (TCP/TCPS).
- Database Identifiers: Logic to handle both Oracle Service Names and SIDs.
- Performance Tuning: Parameters for connection pooling (min/max size, increment) and execution timeouts.
- Materialization Settings: Validates dbt materialization types such as
table,view,incremental, andsnapshot.
Sources: tests/unit/_config_parts/connection.py:11-105, rules.json:15-30
Connection String Generation
The system dynamically generates connection strings based on the presence of a SID or a Service Name. If a SID is provided, the separator : is used; otherwise, / is used for Service Names.
The diagram shows the logic path for determining the correct Oracle URL format based on the database identifier type.
Sources: tests/unit/_config_parts/connection.py:16-41
Validation Logic
The implementation includes strict validation rules to ensure the environment is correctly configured before any database operations occur.
Mandatory Fields and Type Safety
The system enforces the presence of required fields defined in the project rules, including host, username, password, and schema. Validation tests verify that invalid types for protocols or materializations are caught at initialization.
| Parameter | Type | Valid Values / Constraints |
|---|---|---|
protocol | String | tcp, tcps |
materialization | Enum | table, view, incremental, snapshot |
port | Integer | >= 1 |
pool_max_size | Integer | Must be >= pool_min_size |
query_timeout | Integer | > 0 |
Sources: rules.json:32-37, tests/unit/_config_parts/validation.py:46-85, tests/unit/test_connections.py:75-78
Metadata and Relation Mapping
The OracleTableAdapter class is tested to ensure it correctly maps schema and table names into full Oracle relation strings.
def test_relation_name(self) -> None:
adapter = m.DbtOracle.OracleTableAdapter(
schema_name="HR",
table_name="EMPLOYEES",
)
assert adapter.relation_name == "HR.EMPLOYEES"
Sources: tests/unit/test_impl.py:14-20
Integration with Oracle Primitives
Tests in test_connections.py focus on the OracleConnectionConfig class, which handles the low-level DSN construction and default value application.
Default Value Handling
When not explicitly provided, the system applies default values for standard Oracle configurations, such as port 1521 and protocol tcp.
The class diagram illustrates the relationship between the high-level dbt settings and the lower-level connection configuration used for DSN generation.
Sources: tests/unit/test_connections.py:16-30, tests/unit/_config_parts/connection.py:65-80
DSN Construction
The DSN (Data Source Name) property provides the formatted connection string required by Oracle drivers, obfuscating passwords with *** in string representations for security.
Sources: tests/unit/test_connections.py:53-73
Summary
The Connection Implementation Tests provide a robust validation layer for the flext-dbt-oracle adapter. By testing construction, validation, and conversion logic across multiple scenarios—including both Service Name and SID configurations—the project ensures that connection parameters are handled safely and consistently. These tests also verify the correct mapping of performance settings and dbt materialization types, aligning the adapter's configuration with Oracle's specific requirements.