Skip to content

Commit 5439cdb

Browse files
andronicsclaude
andcommitted
Phase 3 Tests: Transform Base & Pipeline - 99% coverage achieved
Implemented comprehensive test suites for core transform components: ## Test Coverage Achieved: ### Transform Base Classes (test_base.py - 33 tests) - 98.82% coverage (79/80 lines, only abstract pass statement uncovered) - Tests for Transform abstract base class - TransformResult dataclass - TransformError exception - Transform lifecycle hooks (before/after) - Statistics tracking (success/fail rates, timing) - Enable/disable functionality - Metadata passthrough - Error handling and graceful degradation ### TransformPipeline (test_transform_pipeline.py - 34 tests) - 99.37% coverage (119/120 lines, only lock exit branch uncovered) - Sequential transform chain execution - Graceful error handling (halt/continue modes) - Transform result caching with SHA256 keys - Cache hit/miss statistics - Thread-safety testing - Enable/disable transforms dynamically - Multiple transform chaining - Error propagation modes ## Test Highlights: **Base Transform Tests**: - Simple, Failing, and Conditional transform implementations - Hook transform for lifecycle testing - Mixed success/failure statistics - Timing accuracy validation - Metadata passthrough verification **Pipeline Tests**: - No transforms, single transform, chained transforms - Disabled transform skipping - Unsupported path skipping - Error handling (continue vs halt) - Cache key generation (content, path, transform config) - Statistics aggregation - Thread-safe concurrent operations (10 threads) - Enable/disable runtime control ## Fixes Made: **TransformPipeline CacheManager Integration**: - Fixed CacheManager initialization (CacheConfig with max_entries, max_size_bytes) - Updated get() to use namespace + key + level API - Updated set() to include size parameter - Updated clear() to specify cache level ## Test Results: - **Total tests**: 67 (33 base + 34 pipeline) - **All passing**: 100% success rate - **Base coverage**: 98.82% - **Pipeline coverage**: 99.37% - **Combined average**: 99.1% coverage Next: Tests for TemplateTransform, CompressionTransform, FormatConversionTransforms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 77d3fdb commit 5439cdb

3 files changed

Lines changed: 984 additions & 6 deletions

File tree

shadowfs/integration/transform_pipeline.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ def __init__(
5555

5656
# Initialize cache if enabled
5757
if cache_enabled:
58-
from shadowfs.infrastructure import CacheLevel
58+
from shadowfs.infrastructure import CacheConfig, CacheLevel
5959

60-
self._cache = CacheManager(
61-
max_size_mb=256, ttl_seconds=cache_ttl, level=CacheLevel.L3
60+
cache_config = CacheConfig(
61+
max_entries=10000,
62+
max_size_bytes=256 * 1024 * 1024, # 256 MB
63+
ttl_seconds=cache_ttl,
64+
enabled=True,
6265
)
66+
# Create simple single-level cache manager
67+
self._cache = CacheManager(configs={CacheLevel.L3: cache_config})
6368
else:
6469
self._cache = None
6570

@@ -141,7 +146,9 @@ def apply(
141146
# Check cache first
142147
if self._cache_enabled and not skip_cache:
143148
cache_key = self._get_cache_key(content, path)
144-
cached = self._cache.get(cache_key)
149+
from shadowfs.infrastructure import CacheLevel
150+
151+
cached = self._cache.get("transform", cache_key, CacheLevel.L3)
145152
if cached is not None:
146153
self._stats["cache_hits"] += 1
147154
self._logger.debug(f"Transform cache hit for {path}")
@@ -203,7 +210,11 @@ def apply(
203210
# Cache result if successful
204211
if self._cache_enabled and not skip_cache and all_success:
205212
cache_key = self._get_cache_key(content, path)
206-
self._cache.set(cache_key, final_result)
213+
from shadowfs.infrastructure import CacheLevel
214+
215+
# Estimate size
216+
result_size = len(final_result.content) + 1024 # Content + metadata overhead
217+
self._cache.set("transform", cache_key, final_result, result_size, CacheLevel.L3)
207218

208219
return final_result
209220

@@ -269,7 +280,9 @@ def reset_stats(self) -> None:
269280
def clear_cache(self) -> None:
270281
"""Clear transform cache."""
271282
if self._cache:
272-
self._cache.clear()
283+
from shadowfs.infrastructure import CacheLevel
284+
285+
self._cache.clear(CacheLevel.L3)
273286

274287
def enable_transform(self, name: str) -> bool:
275288
"""Enable transform by name.

0 commit comments

Comments
 (0)