33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock, patch
|
|
from infra_cli.proxmox import ProxmoxManager
|
|
|
|
class MockConfig:
|
|
def get_node(self, name):
|
|
return {"host": "1.2.3.4", "pass": "secret"}
|
|
def get(self, key, default=None):
|
|
return default
|
|
|
|
@patch('infra_cli.proxmox.SSHClient')
|
|
def test_template_resolution(mock_ssh):
|
|
# Setup mock SSH response
|
|
mock_instance = mock_ssh.return_value
|
|
mock_instance.run.return_value.returncode = 0
|
|
mock_instance.run.return_value.stdout = "local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst tzst vztmpl 129710398"
|
|
|
|
mgr = ProxmoxManager(MockConfig())
|
|
resolved = mgr.resolve_template("debian-13")
|
|
|
|
assert resolved == "local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst"
|
|
mock_instance.run.assert_called_with("pvesm list --content vztmpl | grep 'debian-13-standard' | sort -V | tail -n 1")
|
|
|
|
@patch('infra_cli.proxmox.SSHClient')
|
|
def test_storage_discovery(mock_ssh):
|
|
mock_instance = mock_ssh.return_value
|
|
mock_instance.run.return_value.returncode = 0
|
|
mock_instance.run.return_value.stdout = "local-zfs zfspool active 1000 500 500 50%"
|
|
|
|
mgr = ProxmoxManager(MockConfig())
|
|
storage = mgr.discover_storage()
|
|
|
|
assert storage == "local-zfs"
|