2022-03-08 22:56:38 +00:00
|
|
|
"""Test Host class."""
|
2024-03-07 10:50:43 +00:00
|
|
|
|
2022-03-08 22:56:38 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from prometheuspvesd.model import Host
|
|
|
|
|
|
|
|
pytest_plugins = [
|
|
|
|
"prometheuspvesd.test.fixtures.fixtures",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2024-01-24 11:50:39 +00:00
|
|
|
"testinput,expected",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
{
|
|
|
|
"vmid": 101,
|
|
|
|
"hostname": "host1",
|
|
|
|
"ipv4_address": False,
|
|
|
|
"ipv6_address": False,
|
|
|
|
"pve_type": "qemu",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__meta_pve_vmid": "101",
|
|
|
|
"__meta_pve_name": "host1",
|
|
|
|
"__meta_pve_ipv4": "False",
|
|
|
|
"__meta_pve_ipv6": "False",
|
|
|
|
"__meta_pve_type": "qemu",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
{
|
|
|
|
"vmid": "202",
|
|
|
|
"hostname": "host2",
|
|
|
|
"ipv4_address": "129.168.0.1",
|
|
|
|
"ipv6_address": "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
|
|
"pve_type": "qemu",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"__meta_pve_vmid": "202",
|
|
|
|
"__meta_pve_name": "host2",
|
|
|
|
"__meta_pve_ipv4": "129.168.0.1",
|
|
|
|
"__meta_pve_ipv6": "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
|
|
"__meta_pve_type": "qemu",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
2022-03-08 22:56:38 +00:00
|
|
|
)
|
2022-04-04 20:43:00 +00:00
|
|
|
def test_host(testinput, expected):
|
2022-03-08 22:56:38 +00:00
|
|
|
host = Host(
|
|
|
|
testinput["vmid"],
|
|
|
|
testinput["hostname"],
|
|
|
|
testinput["ipv4_address"],
|
|
|
|
testinput["ipv6_address"],
|
|
|
|
testinput["pve_type"],
|
|
|
|
)
|
|
|
|
|
|
|
|
assert host.labels == expected
|