Files
ss-tools/backend/tests/test_storage_audit_fixes.py
busya 31680a1bc9 fix(maintenance): auto-expiry + adaptive markdown height + tests
- Auto-expiry: expired events auto-end on GET /events via task manager
- Height: _estimate_markdown_height adapted to unit=8px scale with padding detection
- CRITICAL-1: removed dead import remove_chart_from_position (QA finding)
- CRITICAL-2: added chart alive check in ensure_banner_chart (QA finding)
- CRITICAL-3: fixed test assertions update_markdown_chart → update_banner_on_dashboard
- @POST contract: fixed return range [2,12] → [19,200]
- Tests: 8 new tests (auto-expiry + layout height)
2026-05-25 08:36:33 +03:00

70 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
import sys
from pathlib import Path
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):
from src.models.storage import FileCategory, StorageConfig, StoredFile
# Verify instantiation of StoredFile with all required fields
from datetime import datetime
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