"""Conftest for operations unit tests - handles vhost validation mocking."""

from unittest.mock import AsyncMock, MagicMock, patch

import pytest

from rabbitmq_mcp_connection.http_client import HTTPClientManager


@pytest.fixture(autouse=True)
def auto_mock_vhost_validation(monkeypatch):
    """Automatically mock vhost validation for all operations tests."""

    # Create an async mock that always succeeds
    mock_validator = AsyncMock()
    mock_validator.return_value = None  # Successful validation returns None

    # Patch the VhostValidator.validate_vhost method
    monkeypatch.setattr(
        "rabbitmq_mcp_connection.middleware.vhost_validator.VhostValidator.validate_vhost",
        mock_validator,
    )


@pytest.fixture
def mock_http_client():
    """Create mock HTTPClientManager."""
    client = MagicMock(spec=HTTPClientManager)
    client.request = AsyncMock()
    return client
