Files
ss-tools/backend/tests/core/test_defensive_guards.py

25 lines
920 B
Python

import pytest
from unittest.mock import MagicMock
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_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)