netbox-agent/tests/server.py

92 lines
2.9 KiB
Python
Raw Normal View History

2020-02-02 20:08:56 +01:00
from netbox_agent.dmidecode import parse
from netbox_agent.server import ServerBase
2020-07-13 20:34:04 +02:00
from netbox_agent.vendors.hp import HPHost
from netbox_agent.vendors.qct import QCTHost
from netbox_agent.vendors.supermicro import SupermicroHost
2020-02-02 20:08:56 +01:00
from tests.conftest import parametrize_with_fixtures
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/")
2020-02-02 20:08:56 +01:00
def test_init(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
assert server
@parametrize_with_fixtures(
2024-10-21 12:55:54 +02:00
"dmidecode/",
only_filenames=[
"HP_SL4540_Gen8",
"HP_BL460c_Gen9",
"HP_DL380p_Gen8",
"HP_SL4540_Gen8" "HP_ProLiant_BL460c_Gen10_Graphics_Exp",
],
)
2020-02-02 20:08:56 +01:00
def test_hp_service_tag(fixture):
dmi = parse(fixture)
2020-07-13 20:34:04 +02:00
server = HPHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "4242"
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["HP_ProLiant_m710x"])
def test_moonshot_blade(fixture):
dmi = parse(fixture)
server = HPHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "CN66480BLA"
assert server.get_chassis_service_tag() == "CZ3702MD5K"
assert server.is_blade() is True
assert server.own_expansion_slot() is False
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["SYS-5039MS-H12TRF-OS012.txt"])
2020-07-13 20:34:04 +02:00
def test_supermicro_blade(fixture):
dmi = parse(fixture)
server = SupermicroHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "E235735X6B01665"
assert server.get_chassis_service_tag() == "C9390AF40A20098"
assert server.get_chassis() == "SYS-5039MS-H12TRF-OS012"
2020-07-13 20:34:04 +02:00
assert server.is_blade() is True
2020-07-29 00:21:08 +02:00
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["SM_SYS-6018R"])
2020-07-13 20:34:04 +02:00
def test_supermicro_pizza(fixture):
dmi = parse(fixture)
server = SupermicroHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "A177950X7709591"
assert server.get_chassis() == "SYS-6018R-TDTPR"
2020-07-13 20:34:04 +02:00
assert server.is_blade() is False
2020-07-29 00:21:08 +02:00
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["QCT_X10E-9N"])
2020-07-28 18:51:15 +02:00
def test_qct_x10(fixture):
dmi = parse(fixture)
server = QCTHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "QTFCQ57140285"
2020-07-28 18:51:15 +02:00
2020-07-29 00:21:08 +02:00
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["unknown.txt"])
def test_generic_host_service_tag(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "42"
2024-10-21 12:55:54 +02:00
@parametrize_with_fixtures("dmidecode/", only_filenames=["unknown.txt"])
def test_generic_host_product_name(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_product_name() == "SR"
@parametrize_with_fixtures(
2024-10-21 12:55:54 +02:00
"dmidecode/", only_filenames=["HP_ProLiant_BL460c_Gen10_Graphics_Exp"]
)
def test_hp_blade_with_gpu_expansion(fixture):
dmi = parse(fixture)
server = HPHost(dmi)
2024-10-21 12:55:54 +02:00
assert server.get_service_tag() == "4242"
assert server.get_chassis_service_tag() == "4343"
assert server.is_blade() is True
assert server.own_expansion_slot() is True
2024-10-21 12:55:54 +02:00
assert server.get_expansion_service_tag() == "4242 expansion"