Test Fixtures & Config
Relevant source files
The following files were used as context for generating this wiki page:
The Test Fixtures & Config module provides a standardized framework for validating the Oracle Integration Cloud (OIC) Singer Tap. This system leverages pytest and specialized utility classes to ensure the tap correctly handles authentication, configuration validation, and stream discovery. It utilizes pydantic-settings for robust environment-based configuration and MagicMock for isolating authentication logic during unit testing.
The testing infrastructure is designed to validate both core tap functionality and extended capabilities, such as infrastructure stream discovery and complex OAuth2 handshake procedures. Sources: tests/unit/test_tap_core.py:1-10, pyproject.toml:120-160
Testing Infrastructure & Dependencies
The project uses a comprehensive suite of development dependencies to manage test execution, linting, and type checking. The core testing framework is pytest, supplemented by plugins for coverage, mocking, and environmental variable management.
Key Testing Tools
| Tool | Purpose | Source |
|---|---|---|
pytest | Primary test runner and fixture provider | pyproject.toml:115 |
pytest-mock | Provides mocker fixtures for dependency injection and mocking | pyproject.toml:111 |
pytest-env | Manages environment variables during test sessions | pyproject.toml:110 |
pytest-cov | Generates code coverage reports (threshold set to 20%) | pyproject.toml:107, pyproject.toml:205 |
hypothesis | Property-based testing support | pyproject.toml:98 |
factory-boy | Used for generating test data/models | pyproject.toml:96 |
Configuration & Environment Management
The tap's configuration is driven by the FlextTapOracleOicSettings class, which uses an environment prefix FLEXT_TAP_ORACLE_OIC_. Tests simulate these settings using dictionary mappings or mocked settings objects.
Config Validation Logic
Tests ensure that the tap fails loudly when required fields are missing or invalid. Validation covers standard strings, SecretStr for sensitive data, and PositiveInt for numeric constraints.
Test Configuration Parameters
| Parameter | Description | Requirement |
|---|---|---|
base_url | OIC instance URL | Required |
oauth_client_id | OAuth2 Client Identifier | Required |
oauth_client_secret | OAuth2 Client Secret (SecretStr) | Required |
oauth_token_url | Identity Cloud Service (IDCS) Token URL | Required |
include_extended | Boolean toggle for metadata streams | Optional (Default: False) |
Sources: src/flext_tap_oracle_oic/settings.py:37-60, tests/unit/test_tap.py:46-52
Authentication Mocking
Authentication tests use the TestsFlextTapOracleOicAuth class to verify the FlextOracleOicAuthenticator. This involves mocking the FlextApi client to simulate various HTTP responses from the Oracle Identity Cloud Service (IDCS).
Auth Mocking Components
mock_configfixture: Mimics theFlextTapOracleOicSettingsto provide client IDs and secrets without accessing real environment variables.authenticatorfixture: Creates an instance of the authenticator by bypassing__init__to avoid side effects, then manually injecting the mocked config and API client.
Sources: tests/unit/test_auth.py:28-56, src/flext_tap_oracle_oic/tap.py:36-45
Stream Discovery Fixtures
The test suite validates the discover_streams capability by building temporary tap instances. It distinguishes between "Core" streams and "Extended" or "Infrastructure" streams based on the provided configuration.
Stream Discovery Flow
The testing utility _discover_stream_names builds a TapInstance and asserts that the resulting catalog contains expected stream identifiers.
Test Utilities & Lazy Loading
The tests/utilities.py file provides a skeleton for domain-specific test helpers, extending FlextTestsUtilities. Additionally, the test package uses a "Lazy Loading" pattern to manage the import of test classes and constants, improving performance by avoiding heavy imports during the collection phase.
Test Namespaces
The tests/__init__.py file uses install_lazy_exports to map test modules to their respective classes:
TestsFlextTapOracleOicAuth->.unit.test_authTestsFlextTapOracleOicTap->.unit.test_tapu->.utilities
Sources: tests/utilities.py:16-24, tests/init.py:47-85
Conclusion
The "Test Fixtures & Config" system provides the necessary scaffolding to maintain the reliability of the Oracle OIC Tap. By using Pydantic for configuration validation and comprehensive mocking for the OAuth2 flow, the suite ensures that the tap remains resilient against API changes and configuration errors. The structure allows for easy extension as new OIC resources are added to the stream registry.