Skip to content

Dianel555/DSkills / skills/serena

serena

Verified

Semantic code understanding with IDE-like symbol operations. Use when: (1) Large codebase analysis (>50 files), (2) Symbol-level operations (find, rename, refactor), (3) Cross-file reference tracking, (4) Project memory and session persistence, (5) Multi-language semantic navigation. Triggers: "find symbol", "rename function", "find references", "symbol overview", "project memory". IMPORTANT: Prioritize Serena's symbolic tools over file-based grep/read for code exploration.

tools/tests/test_paths.py

View on GitHub
"""Tests for path resolution module."""
import os
from pathlib import Path
from unittest.mock import patch
import tempfile


def test_get_config_dir_default():
    """Test default config directory resolution."""
    from tools.paths import SerenaToolsPaths

    paths = SerenaToolsPaths()
    config_dir = paths.get_config_dir()

    # Should resolve to ~/.serena
    expected = Path.home() / ".serena"
    assert config_dir == expected


def test_get_config_dir_with_serena_home():
    """Test config directory with SERENA_HOME override."""
    from tools.paths import SerenaToolsPaths

    with tempfile.TemporaryDirectory() as tmpdir:
        with patch.dict(os.environ, {"SERENA_HOME": tmpdir}):
            paths = SerenaToolsPaths()
            config_dir = paths.get_config_dir()

            assert config_dir == Path(tmpdir)


def test_get_config_file_path():
    """Test config file path resolution."""
    from tools.paths import SerenaToolsPaths

    paths = SerenaToolsPaths()
    config_file = paths.get_config_file_path()

    # Should resolve to ~/.serena/serena_config.yml
    expected = Path.home() / ".serena" / "serena_config.yml"
    assert config_file == expected


def test_ensure_config_exists_creates_directory():
    """Test that ensure_config_exists creates config directory."""
    from tools.paths import SerenaToolsPaths

    with tempfile.TemporaryDirectory() as tmpdir:
        with patch.dict(os.environ, {"SERENA_HOME": tmpdir}):
            paths = SerenaToolsPaths()
            config_file = paths.ensure_config_exists()

            # Directory should be created
            assert config_file.parent.exists()
            assert config_file.parent.is_dir()


def test_ensure_config_exists_creates_file():
    """Test that ensure_config_exists creates config file if missing."""
    from tools.paths import SerenaToolsPaths

    with tempfile.TemporaryDirectory() as tmpdir:
        with patch.dict(os.environ, {"SERENA_HOME": tmpdir}):
            paths = SerenaToolsPaths()
            config_file = paths.ensure_config_exists()

            # Config file should be created
            assert config_file.exists()
            assert config_file.is_file()


def test_ensure_config_exists_preserves_existing():
    """Test that ensure_config_exists preserves existing config."""
    from tools.paths import SerenaToolsPaths

    with tempfile.TemporaryDirectory() as tmpdir:
        with patch.dict(os.environ, {"SERENA_HOME": tmpdir}):
            # Create existing config
            config_dir = Path(tmpdir)
            config_dir.mkdir(exist_ok=True)
            config_file = config_dir / "serena_config.yml"
            config_file.write_text("existing: config")

            paths = SerenaToolsPaths()
            result = paths.ensure_config_exists()

            # Should preserve existing content
            assert result.read_text() == "existing: config"
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall