Files
ss-tools/backend/tests/core/test_defensive_guards.py
busya f34f9c1b2e test: remediate and stabilize auxiliary backend and frontend tests
- Standardized task log, LLM provider, and report profile tests.
- Relocated auxiliary tests into __tests__ directories for consistency.
- Updated git_service and defensive guards with minor stability fixes discovered during testing.
- Added UX integration tests for the reports list component.
2026-03-04 13:54:06 +03:00

42 lines
1.4 KiB
Python

import sys
from pathlib import Path
import shutil
import pytest
from unittest.mock import MagicMock
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from src.services.git_service import GitService
from src.core.superset_client import SupersetClient
from src.core.config_models import Environment
def test_git_service_get_repo_path_guard():
"""Verify that _get_repo_path raises ValueError if dashboard_id is None."""
service = GitService(base_path="test_repos")
with pytest.raises(ValueError, match="dashboard_id cannot be None"):
service._get_repo_path(None)
def test_git_service_get_repo_path_recreates_base_dir():
"""Verify _get_repo_path recreates missing base directory before returning repo path."""
service = GitService(base_path="test_repos_runtime_recreate")
shutil.rmtree(service.base_path, ignore_errors=True)
repo_path = service._get_repo_path(42)
assert Path(service.base_path).is_dir()
assert repo_path == str(Path(service.base_path) / "42")
def test_superset_client_import_dashboard_guard():
"""Verify that import_dashboard raises ValueError if file_name is None."""
mock_env = Environment(
id="test",
name="test",
url="http://localhost:8088",
username="admin",
password="admin"
)
client = SupersetClient(mock_env)
with pytest.raises(ValueError, match="file_name cannot be None"):
client.import_dashboard(None)