Skip to content

Commit b5d02d1

Browse files
robotdadclaude
andauthored
fix: resolve TranscriptStorage dual-directory test failure (#75)
* fix: resolve TranscriptStorage dual-directory test failure Fixed bug where TranscriptStorage would save files to production .data directory even when initialized with a test-specific temporary directory. Changes: - Added test mode detection based on custom output_dir parameter - In test mode, both output_dir and data_dir use the same directory - In production, maintains dual-directory architecture (content vs artifacts) - Added property setters to keep directories synchronized This ensures tests work with temporary directories while preserving the dual-directory architecture for production use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: remove unnecessary return statement from test Removed `return True` from test_cache_functionality() to eliminate pytest warning about test functions returning non-None values. Pytest uses assertions to determine pass/fail, not return values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent b2b8afa commit b5d02d1

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

scenarios/transcribe/storage/core.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,48 @@ def __init__(self, output_dir: Path | None = None):
2626
Args:
2727
output_dir: Base output directory (default: AMPLIFIER_CONTENT_DIRS/transcripts)
2828
"""
29+
# Track if we're in test mode (custom output directory provided)
30+
self._test_mode = output_dir is not None
31+
2932
if output_dir:
30-
self.output_dir = output_dir
33+
# Custom output directory (test scenario)
34+
# Use the provided directory as base for both content and data
35+
self._output_dir = output_dir
36+
self._data_dir = output_dir # In test mode, keep everything together
3137
else:
38+
# Production scenario - use dual-directory architecture
3239
# Use first content directory if available, otherwise fall back to data_dir
3340
content_dirs = paths.get_all_content_paths()
3441
if content_dirs:
35-
self.output_dir = content_dirs[0] / "transcripts"
42+
self._output_dir = content_dirs[0] / "transcripts"
3643
else:
3744
logger.warning("No content directories found, using .data/transcripts instead")
38-
self.output_dir = paths.data_dir / "transcripts"
39-
self.output_dir.mkdir(parents=True, exist_ok=True)
40-
41-
# Add data dir for technical artifacts (JSON, VTT, SRT)
42-
self.data_dir = paths.data_dir / "transcripts"
43-
self.data_dir.mkdir(parents=True, exist_ok=True)
45+
self._output_dir = paths.data_dir / "transcripts"
46+
47+
# In production, technical artifacts go to .data directory
48+
self._data_dir = paths.data_dir / "transcripts"
49+
self._data_dir.mkdir(parents=True, exist_ok=True)
50+
51+
self._output_dir.mkdir(parents=True, exist_ok=True)
52+
53+
@property
54+
def output_dir(self) -> Path:
55+
"""Get the output directory."""
56+
return self._output_dir
57+
58+
@output_dir.setter
59+
def output_dir(self, value: Path) -> None:
60+
"""Set the output directory. In test mode, also updates data_dir."""
61+
self._output_dir = value
62+
if self._test_mode:
63+
# Keep data_dir synchronized with output_dir in test mode
64+
self._data_dir = value
65+
self._output_dir.mkdir(parents=True, exist_ok=True)
66+
67+
@property
68+
def data_dir(self) -> Path:
69+
"""Get the data directory."""
70+
return self._data_dir
4471

4572
def save(
4673
self,

scenarios/transcribe/test_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def test_cache_functionality():
116116
logger.info("✓ JSON metadata includes audio info correctly")
117117

118118
logger.info("\n✅ All cache functionality tests passed!")
119-
return True
120119

121120

122121
if __name__ == "__main__":

0 commit comments

Comments
 (0)