"""Tests for execute_ruff_fix - No files scenarios."""

from __future__ import annotations

from typing import Any
from unittest.mock import MagicMock, patch

from assertpy import assert_that

from lintro.tools.implementations.ruff.fix import execute_ruff_fix


def test_execute_ruff_fix_no_paths(mock_ruff_tool: MagicMock) -> None:
    """Return success with no files message when paths list is empty.

    Args:
        mock_ruff_tool: Mock RuffTool instance for testing.
    """
    result = execute_ruff_fix(mock_ruff_tool, [])

    assert_that(result.success).is_true()
    assert_that(result.output).is_equal_to("No files to fix.")
    assert_that(result.issues_count).is_equal_to(0)


def test_execute_ruff_fix_no_python_files_found(
    mock_ruff_tool: MagicMock,
    tmp_path: Any,
) -> None:
    """Return success with no Python files message when no .py files exist.

    Args:
        mock_ruff_tool: Mock RuffTool instance for testing.
        tmp_path: Temporary directory path for testing.
    """
    # Create a non-Python file
    text_file = tmp_path / "readme.txt"
    text_file.write_text("Hello")

    with patch(
        "lintro.tools.implementations.ruff.fix.walk_files_with_excludes",
    ) as mock_walk:
        mock_walk.return_value = []

        result = execute_ruff_fix(mock_ruff_tool, [str(tmp_path)])

    assert_that(result.success).is_true()
    assert_that(result.output).is_equal_to("No Python files found to fix.")
    assert_that(result.issues_count).is_equal_to(0)
