Warnings fixed: - datetime.utcnow() → datetime.now(UTC) across 48+ files (src/ + tests/) - datetime.utcnow (callback ref) → lambda: datetime.now(UTC) in model fields (18 files) - Pydantic class Config → model_config = ConfigDict(...) (16 files) - Pydantic .dict() → .model_dump() (8 files) - ConfigDict(allow_population_by_field_name=True) → validate_by_name=True - SQLAlchemy declarative_base() import path updated - FastAPI on_event → lifespan context manager (app.py) - Import sorting (ruff I001) auto-fixed across all files - Fixed broken re-export chains that ruff F401 cleanup broke: _validate_bcp47: service.py now imports from dictionary_validation directly job_to_response: _job_routes.py and test imports from service_utils directly fetch_datasource_metadata: restored re-export in service.py - Added missing TranslateJobService import in _job_routes.py (was deleted by F401) - Added ConfigDict(protected_namespaces=()) for DashboardDatasetItem schema field - pytest.ini: replaced deprecated importmode with asyncio_mode All 440 tests pass with zero deprecation warnings.
71 lines
3.1 KiB
Python
71 lines
3.1 KiB
Python
# #region TestStorageAuditFixes [C:3] [TYPE Module] [SEMANTICS test,storage,typo,audit]
|
|
# @BRIEF Verify Class 7 typo fix — "repositorys" → "repositories" across all storage/git modules.
|
|
# @RELATION BINDS_TO -> [StorageModels]
|
|
# @RELATION BINDS_TO -> [GitServiceBase]
|
|
# @TEST_EDGE: typo_regression -> FileCategory.REPOSITORY == "repositories" (not "repositorys")
|
|
# @TEST_EDGE: default_path -> StorageConfig().repo_path defaults to "repositories"
|
|
# @TEST_EDGE: git_typo_regression -> No "repositorys" string exists in storage/git source files
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
|
|
|
|
class TestStorageAuditFixes:
|
|
"""Verify the "repositorys" → "repositories" typo fix."""
|
|
|
|
# #region test_repository_typo_fixed [C:2] [TYPE Function]
|
|
# @BRIEF FileCategory.REPOSITORY equals "repositories", NOT "repositorys".
|
|
def test_repository_typo_fixed(self):
|
|
from src.models.storage import FileCategory
|
|
assert FileCategory.REPOSITORY == "repositories"
|
|
assert FileCategory.REPOSITORY.value == "repositories"
|
|
# #endregion test_repository_typo_fixed
|
|
|
|
# #region test_repo_path_default_fixed [C:2] [TYPE Function]
|
|
# @BRIEF StorageConfig().repo_path defaults to "repositories".
|
|
def test_repo_path_default_fixed(self):
|
|
from src.models.storage import StorageConfig
|
|
config = StorageConfig()
|
|
assert config.repo_path == "repositories"
|
|
# #endregion test_repo_path_default_fixed
|
|
|
|
# #region test_storage_model_compiles [C:2] [TYPE Function]
|
|
# @BRIEF All storage model classes import without errors.
|
|
def test_storage_model_compiles(self):
|
|
# Verify instantiation of StoredFile with all required fields
|
|
from datetime import datetime
|
|
|
|
from src.models.storage import FileCategory, StoredFile
|
|
f = StoredFile(
|
|
name="test.txt",
|
|
path="backups/test.txt",
|
|
size=42,
|
|
created_at=datetime.now(),
|
|
category=FileCategory.BACKUP,
|
|
)
|
|
assert f.name == "test.txt"
|
|
assert f.size == 42
|
|
assert f.category == FileCategory.BACKUP
|
|
# #endregion test_storage_model_compiles
|
|
|
|
# #region test_backup_category_unchanged [C:2] [TYPE Function]
|
|
# @BRIEF FileCategory.BACKUP still equals "backups" (not affected by typo fix).
|
|
def test_backup_category_unchanged(self):
|
|
from src.models.storage import FileCategory
|
|
assert FileCategory.BACKUP == "backups"
|
|
# #endregion test_backup_category_unchanged
|
|
|
|
# #region test_storage_config_fields_have_correct_types [C:2] [TYPE Function]
|
|
# @BRIEF StorageConfig fields are all strings with correct defaults.
|
|
def test_storage_config_fields_have_correct_types(self):
|
|
from src.models.storage import StorageConfig
|
|
config = StorageConfig()
|
|
assert isinstance(config.root_path, str)
|
|
assert isinstance(config.backup_path, str)
|
|
assert isinstance(config.repo_path, str)
|
|
assert config.root_path == "/app/storage"
|
|
assert config.backup_path == "backups"
|
|
# #endregion test_storage_config_fields_have_correct_types
|
|
# #endregion TestStorageAuditFixes
|