Domain Specific Tooling
Relevant source files
The following files were used as context for generating this wiki page:
Domain Specific Tooling in the flext-tests ecosystem provides a specialized infrastructure for managing domain-focused test data, fixtures, and result handling. Its primary purpose is to abstract the complexities of environment-specific setups (such as OID/LDAP servers or database schemas) into a unified interface for test developers.
The system relies on a combination of result builders, fixture loaders, and payload utilities to ensure that tests remain isolated, repeatable, and maintainable across different functional domains.
Core Result Management
The tooling provides standardized builders for operation results, ensuring consistent error handling and data structures across domain actions. This is primarily handled via td (Domains) helpers.
Result Builders
The infrastructure supports generating both success and failure results with structured error codes and metadata.
| Method | Purpose | Returns |
|---|---|---|
create_result_ok | Generates a successful operation result with a value. | p.Result[T] |
create_result_failure | Generates a failure result with error message, code, and data. | p.Result[T] |
Sources: tests/unit/test_domains.py:17-31, src/flext_tests/domains.py
The following diagram illustrates the flow of result creation within domain utilities:
Sources: tests/unit/test_domains.py:17-31
Fixture Infrastructure
The td module manages physical test fixtures organized by "servers" (domains) and "types". This structure allows for systematic discovery and loading of external configuration or data files (e.g., .ldif files for LDAP domains).
Fixture Discovery and Loading
The system can identify available domains (servers) and the specific types of fixtures they contain by scanning a root directory.
| Function | Description |
|---|---|
load_fixture | Reads the content of a specific fixture file. |
fixture_exists | Checks for the existence of a specific fixture. |
available_fixture_servers | Lists all directories (servers) within the fixtures root. |
available_fixture_types | Lists all fixture types (files) available for a specific server. |
Sources: tests/unit/test_domains.py:33-61, src/flext_tests/_domains_parts/domains_part_03.py
Fixture Organization Logic
Fixtures are expected to be organized in a directory structure: {fixtures_root}/{server}/{server}_{type}_fixtures.{ext}. For example, an OID schema fixture would be located at oid/oid_schema_fixtures.ldif.
Sources: tests/unit/test_domains.py:36-41
Payload and Handler Utilities
To support domain-specific logic, the project utilizes utility mixins for handling data payloads and executing domain-specific handlers.
Payload Conversion
The FlextTestsPayloadUtilities class provides methods to normalize various data types into standardized formats used by domain models.
to_payload: Converts objects, Pydantic models, or sequences into serializable test objects.to_config_map: Wraps serializable data into aConfigMapfor structured access.
Sources: src/flext_tests/_utilities/payload.py:15-45
Handler Helpers
The FlextTestsHandlerHelpersUtilitiesMixin provides the interface for interacting with domain-specific logic handlers. This includes retrieving handler results and managing the execution context of domain actions.
Sources: src/flext_tests/_utilities/handler.py:10-25, src/flext_tests/_utilities/init.py:125
Summary
The Domain Specific Tooling in flext-tests provides a robust framework for managing test data and operations. By standardizing how results are reported and how fixtures are discovered and loaded, it ensures that domain-specific tests (like those for OID/LDAP or database interactions) remain consistent with the broader project's testing standards. This modular approach allows for easy expansion as new domains are added to the ecosystem.