WIP
This commit is contained in:
68
update_test_imports.py
Normal file
68
update_test_imports.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Update test imports to use new structure."""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
# Import mapping: old -> new
|
||||
IMPORT_MAPPINGS = {
|
||||
# Admin routes
|
||||
r'from src\.web\.admin_routes import': 'from src.web.api.v1.admin.documents import',
|
||||
r'from src\.web\.admin_annotation_routes import': 'from src.web.api.v1.admin.annotations import',
|
||||
r'from src\.web\.admin_training_routes import': 'from src.web.api.v1.admin.training import',
|
||||
|
||||
# Auth and core
|
||||
r'from src\.web\.admin_auth import': 'from src.web.core.auth import',
|
||||
r'from src\.web\.admin_autolabel import': 'from src.web.services.autolabel import',
|
||||
r'from src\.web\.admin_scheduler import': 'from src.web.core.scheduler import',
|
||||
|
||||
# Schemas
|
||||
r'from src\.web\.admin_schemas import': 'from src.web.schemas.admin import',
|
||||
r'from src\.web\.schemas import': 'from src.web.schemas.inference import',
|
||||
|
||||
# Services
|
||||
r'from src\.web\.services import': 'from src.web.services.inference import',
|
||||
r'from src\.web\.async_service import': 'from src.web.services.async_processing import',
|
||||
r'from src\.web\.batch_upload_service import': 'from src.web.services.batch_upload import',
|
||||
|
||||
# Workers
|
||||
r'from src\.web\.async_queue import': 'from src.web.workers.async_queue import',
|
||||
r'from src\.web\.batch_queue import': 'from src.web.workers.batch_queue import',
|
||||
|
||||
# Routes
|
||||
r'from src\.web\.routes import': 'from src.web.api.v1.routes import',
|
||||
r'from src\.web\.async_routes import': 'from src.web.api.v1.async_api.routes import',
|
||||
r'from src\.web\.batch_upload_routes import': 'from src.web.api.v1.batch.routes import',
|
||||
}
|
||||
|
||||
def update_file(file_path: Path) -> bool:
|
||||
"""Update imports in a single file."""
|
||||
content = file_path.read_text(encoding='utf-8')
|
||||
original_content = content
|
||||
|
||||
for old_pattern, new_import in IMPORT_MAPPINGS.items():
|
||||
content = re.sub(old_pattern, new_import, content)
|
||||
|
||||
if content != original_content:
|
||||
file_path.write_text(content, encoding='utf-8')
|
||||
return True
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Update all test files."""
|
||||
test_dir = Path('tests/web')
|
||||
updated_files = []
|
||||
|
||||
for test_file in test_dir.glob('test_*.py'):
|
||||
if update_file(test_file):
|
||||
updated_files.append(test_file.name)
|
||||
|
||||
if updated_files:
|
||||
print(f"✓ Updated {len(updated_files)} test files:")
|
||||
for filename in sorted(updated_files):
|
||||
print(f" - {filename}")
|
||||
else:
|
||||
print("No files needed updating")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user