fix: isolate test artifacts from production asset registry
- Create tests/test_utils.py with utilities for consistent test workspace management - Fix tests to use project tmp/ directory instead of system /tmp - Ensure all AssetManager instances in tests use isolated registries - Prevent contamination of production asset_registry.json during testing Key changes: - test_issue_142_asset_manager.py: Fix AssetManager() calls to use test workspaces - test_issue_144_batch_import.py: Use create_test_workspace() and get_test_asset_config() - test_issue_145_production_error_handler.py: Use test_workspace() context manager - tests/test_utils.py: New utilities for isolated test environments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4b151bb9df
commit
04a9173503
4 changed files with 149 additions and 59 deletions
|
|
@ -8,14 +8,13 @@ Issue #144: Phase 3 - Advanced Features and Performance
|
|||
"""
|
||||
|
||||
import pytest
|
||||
import tempfile
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
import json
|
||||
|
||||
from markitect.assets import AssetManager, AssetError
|
||||
from markitect.assets.batch_processor import BatchAssetProcessor, BatchImportResult, ConflictResolution, ProgressReporter
|
||||
from tests.test_utils import create_test_workspace, get_test_asset_config
|
||||
|
||||
|
||||
class TestBatchAssetImport:
|
||||
|
|
@ -23,9 +22,9 @@ class TestBatchAssetImport:
|
|||
|
||||
def setup_method(self):
|
||||
"""Set up test environment with temporary directories and mock assets."""
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.source_dir = Path(self.temp_dir) / "source"
|
||||
self.assets_dir = Path(self.temp_dir) / "assets"
|
||||
self.temp_dir = create_test_workspace("batch_import")
|
||||
self.source_dir = self.temp_dir / "source"
|
||||
self.assets_dir = self.temp_dir / "assets"
|
||||
|
||||
self.source_dir.mkdir()
|
||||
self.assets_dir.mkdir()
|
||||
|
|
@ -47,16 +46,14 @@ class TestBatchAssetImport:
|
|||
nested_dir.mkdir(parents=True)
|
||||
(nested_dir / "nested_image.png").write_bytes(b"nested content")
|
||||
|
||||
self.asset_manager = AssetManager(config={
|
||||
'assets': {
|
||||
'storage_path': str(self.assets_dir),
|
||||
'registry_path': str(self.assets_dir / 'registry.json')
|
||||
}
|
||||
})
|
||||
# Use test asset configuration to ensure isolated registry
|
||||
config = get_test_asset_config(self.temp_dir)
|
||||
self.asset_manager = AssetManager(config)
|
||||
|
||||
def teardown_method(self):
|
||||
"""Clean up temporary directories."""
|
||||
shutil.rmtree(self.temp_dir)
|
||||
import shutil
|
||||
shutil.rmtree(self.temp_dir, ignore_errors=True)
|
||||
|
||||
def test_batch_processor_initialization(self):
|
||||
"""Test BatchAssetProcessor can be initialized with AssetManager."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue