Testing Strategy & Fixtures
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The FLEXT-LDIF testing strategy implements a multi-layered quality assurance framework designed to ensure RFC 2849 compliance and enterprise-grade LDIF processing. The suite spans from isolated unit tests to complex integration and end-to-end (E2E) workflows, emphasizing high coverage, performance benchmarks, and cross-server compatibility. It leverages a robust fixture system that simulates various LDAP server environments including OID, OUD, and OpenLDAP to validate structural and semantic integrity during parsing, writing, and migration operations.
Sources: tests/README.md:38-42, tests/integration/README.md:25-28
Test Organization and Hierarchy
The project categorizes tests using Pytest markers to facilitate targeted execution and efficient feedback loops. The architecture follows Clean Architecture principles, separating tests by layer and concern.
Test Categories
| Marker | Purpose | Focus Areas |
|---|---|---|
unit | Isolated component testing | Domain entities, utility functions, configuration validation |
integration | Cross-component interaction | API and service integration, DB/FS interaction, dependency injection |
e2e | Complete user workflows | CLI execution, file processing, error recovery |
ldif | Format compliance | RFC 2849 rules, DN hierarchy, attribute validation |
performance | Resource and speed validation | Large file benchmarks, memory usage, scalability |
docker | Containerized integration | Real LDAP server interactions (OpenLDAP) |
Sources: tests/README.md:52-66, tests/integration/README.md:144-158, pyproject.toml:346-360
Testing Workflow
The following diagram illustrates the logical flow of the testing pipeline from individual units to integrated system validation.
The flow shows how different test tiers contribute to the final quality gate before CI deployment.
Sources: tests/README.md:144-162, tests/integration/README.md:364-375
Fixture Management System
The project utilizes a centralized fixture management system defined in conftest.py and tests/fixtures/. This system provides a systematic way to test LDIF functionality against different LDAP server types and data structures.
Fixture Types
Each supported server (RFC, OID, OUD, OpenLDAP) is equipped with four standard fixture types:
- Schema: Defines attributeTypes and objectClasses.
- Entries: Standard directory entries for data validation.
- ACL: Access control list configurations.
- Integration: Complete directory structures combining all elements for full workflow testing.
Sources: tests/fixtures/README.md:22-30, tests/integration/README.md:167-172
Fixture Coverage Matrix
The test_systematic_fixture_coverage.py module ensures that the matrix of 4 servers × 4 fixture types is fully covered.
This matrix ensures that every server implementation can parse and write every fixture category without data loss.
Sources: tests/integration/test_systematic_fixture_coverage.py:16-25
Advanced Integration Testing
Integration tests focus on "Roundtrip Validation," which ensures that data integrity is maintained through a complete lifecycle: Parse -> Write -> Parse.
Roundtrip Logic
The following sequence diagram describes the deep validation process used in integration tests.
Deep content validation ensures that not only is the entry count preserved, but multi-valued attributes and special characters remain unchanged.
Sources: tests/integration/README.md:238-258, tests/integration/test_systematic_fixture_coverage.py:90-112
OUD Specific Integration
Testing OUD integration involves validating Oracle-specific patterns, such as multiline ACIs and specific objectClasses like orclContext or orclPrivilegeGroup. These tests verify that server-specific metadata is preserved and normalized correctly when converted to RFC-compliant formats.
Sources: tests/integration/test_oud_integration.py:85-102, tests/integration/test_oud_integration.py:145-165
Quality Assurance and CI
The testing strategy is governed by strict quality gates defined in pyproject.toml and enforced via make verbs.
Coverage Requirements
The project maintains the following minimum coverage thresholds:
- Overall Coverage: 90%
- Unit Test Coverage: 95% (Domain/Application layers)
- Integration Coverage: 80%
- E2E Coverage: 70%
Sources: tests/README.md:214-222, pyproject.toml:91-95
Performance Targets
| Metric | Target |
|---|---|
| Parsing Speed | > 1000 entries / second |
| Memory Usage | < 1MB per 1000 entries |
| Validation Speed | > 2000 entries / second |
| File Size Support | Up to 1GB |
Sources: tests/README.md:243-248
Test Utilities
The TestsFlextLdifUtilities class in tests/utilities.py provides shared helpers for creating LDAP servers, managing Docker infrastructure, and resolving credentials. It includes a FixtureValidator and a FixtureCoverageReport generator to maintain the health of the fixture library.
Key Utility Functions
create_real_entry(): Generates valid Pydantic models for entries with randomized data.get_docker_control(): Manages shared containers for thedockerandreal_ldapmarkers.assert_server_schema_parse_and_properties(): A unified assertion helper for schema validation across different OIDs and syntaxes.
Sources: tests/utilities.py:75-92, tests/utilities.py:133-145, tests/utilities.py:228-255
Summary
The "Testing Strategy & Fixtures" for FLEXT-LDIF provides a comprehensive safeguard for enterprise directory operations. By combining a systematic fixture matrix with deep roundtrip validation and strict performance benchmarks, the suite ensures that the library remains robust across diverse LDAP server implementations. The focus on automated quality gates and centralized utilities allows for rapid, reliable development while maintaining 90%+ code coverage.
Sources: tests/README.md:10-18, tests/integration/README.md:400-406