Unit Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The unit testing strategy for flext-tap-oracle-oic focuses on validating the core components of the Singer tap for Oracle Integration Cloud (OIC). The primary objective is to ensure that tap initialization, stream discovery, authentication logic, and configuration validation operate correctly under isolated conditions. The project utilizes pytest as the primary test runner, supplemented by specialized plugins for coverage, mocking, and property-based testing.
Sources: pyproject.toml:132-155, tests/unit/test_tap.py:34-40
Testing Infrastructure and Configuration
The project leverages a robust set of development dependencies to enforce code quality and testing standards. Configuration for the testing environment is managed via pyproject.toml, which defines markers, file patterns, and coverage thresholds.
Test Categories
Tests are categorized using pytest markers to allow selective execution of specific test suites:
| Marker | Purpose |
|---|---|
unit | Isolated tests for individual functions and classes. |
integration | Tests focusing on the interaction between multiple modules. |
e2e | Full end-to-end integration tests. |
docker | Tests requiring a Docker environment. |
Sources: pyproject.toml:311-321
Execution Flow
The following diagram illustrates the test execution and validation flow within the CI/CD pipeline or local development environment:
The testing strategy requires a minimum coverage threshold of 20% to pass quality gates.
Sources: pyproject.toml:98-100, pyproject.toml:324-326
Core Tap Testing
Tests in test_tap.py and test_tap_core.py verify the lifecycle and discovery mechanisms of the FlextTapOracleOic class. These tests ensure the tap correctly interprets settings and identifies available data streams.
Tap Initialization
Initialization tests confirm that the tap correctly loads settings into its internal oic_settings object and assigns the proper tap name.
def test_tap_initialization(self) -> None:
settings = {
"base_url": "https://test.integration.ocp.oraclecloud.com",
"oauth_client_id": "test_client",
"oauth_client_secret": "test_secret",
"oauth_token_url": "https://test.identity.oraclecloud.com/oauth2/v1/token",
}
tap = TapOracleOic(settings=settings, validate_config=False)
assert tap.name == "tap-oracle-oic"
assert tap.oic_settings.base_url == settings["base_url"]
Sources: tests/unit/test_tap.py:43-56
Stream Discovery
Discovery logic is tested to ensure that the tap can enumerate mandatory and extended streams. The strategy involves simulating a TapInstance and verifying the returned stream IDs.
- Core Streams: Tests verify the presence of
integrations,connections,packages,lookups, andlibraries. - Extended Streams: Tests validate that setting
include_extended: Trueincludes infrastructure-related streams.
Sources: tests/unit/test_tap_core.py:65-80, tests/unit/test_tap.py:84-106
Authentication Testing
The FlextOracleOicAuthenticator is tested using mocks to simulate the Oracle Identity Cloud Service (IDCS) OAuth2 flow. This ensures the tap can handle various API responses without making actual network calls.
Authentication Sequence
The following sequence diagram represents the mocked authentication testing logic:
Sources: tests/unit/test_auth.py:53-85
Test Scenarios for Auth
| Scenario | Target Validation |
|---|---|
test_get_access_token_success | Verifies successful extraction of the token from a valid JSON response. |
test_get_access_token_bad_status | Ensures failure is handled when the API returns non-200 status codes. |
test_get_access_token_empty_body | Validates robustness against malformed or empty response bodies. |
test_get_access_token_exception | Confirms that network-level exceptions are caught and converted to Result failures. |
Sources: tests/unit/test_auth.py:53-150
Validation Testing
The testing strategy includes negative testing to ensure that invalid configurations are rejected. This leverages Pydantic's TypeAdapter and ValidationError mechanisms.
- Field Type Validation: Tests verify that positive integers cannot be negative.
- Missing Fields: Confirms that required OIC parameters (like
oauth_client_id) are enforced.
Sources: tests/unit/test_tap.py:76-82, tests/unit/test_tap_core.py:126-129
Testing Utilities
The project maintains a structured utility namespace in tests/utilities.py to provide reusable test helpers. This includes the u alias which provides access to TestsFlextTapOracleOicUtilities, facilitating consistent test data generation and validation across the suite.
Sources: tests/utilities.py:1-24
Summary
The unit testing strategy for flext-tap-oracle-oic provides comprehensive coverage of critical tap functions through automated pytest execution, rigorous authentication mocking, and schema-driven configuration validation. By enforcing strict coverage gates and utilizing categorized test markers, the project ensures that any changes to the Oracle Integration Cloud integration are verified for functional correctness and resilience.