"""Shared pytest fixtures for proxmox-mcp.""" from __future__ import annotations import json import os from pathlib import Path from unittest.mock import patch import pytest from proxmox_mcp.config.models import AuthConfig, Config, LoggingConfig, ProxmoxConfig @pytest.fixture def mock_env_vars(): """Set up test environment variables.""" env_vars = { "PROXMOX_HOST": "test.proxmox.com", "PROXMOX_USER": "test@pve", "PROXMOX_TOKEN_NAME": "test_token", "PROXMOX_TOKEN_VALUE": "test_value", "LOG_LEVEL": "DEBUG", } with patch.dict(os.environ, env_vars): yield env_vars @pytest.fixture def test_config() -> Config: return Config( proxmox=ProxmoxConfig(host="test.proxmox.com", verify_ssl=False), auth=AuthConfig( user="test@pve", token_name="test_token", token_value="test_value", ), logging=LoggingConfig(level="DEBUG"), ) @pytest.fixture def mock_proxmox(): """Mock ProxmoxAPI construction.""" with patch("proxmox_mcp.core.proxmox.ProxmoxAPI") as mock: mock.return_value.nodes.get.return_value = [ {"node": "node1", "status": "online"}, {"node": "node2", "status": "online"}, ] yield mock @pytest.fixture def server(mock_env_vars, mock_proxmox, test_config): """Create a ProxmoxMCPServer with mocked config and API.""" with patch("proxmox_mcp.server.load_config", return_value=test_config): from proxmox_mcp.server import ProxmoxMCPServer return ProxmoxMCPServer()