netbox-agent/tests/server.py

80 lines
2 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
@parametrize_with_fixtures('dmidecode/')
def test_init(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
assert server
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'HP_SL4540_Gen8',
'HP_BL460c_Gen9',
'HP_DL380p_Gen8',
'HP_SL4540_Gen8'
])
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)
2020-02-02 20:08:56 +01:00
assert server.get_service_tag() == '4242'
2020-07-13 20:34:04 +02:00
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'SYS-5039MS-H12TRF-OS012.txt'
])
def test_supermicro_blade(fixture):
dmi = parse(fixture)
server = SupermicroHost(dmi)
assert server.get_service_tag() == 'E235735X6B01665'
assert server.get_chassis_service_tag() == 'C9390AF40A20098'
assert server.is_blade() is True
2020-07-29 00:21:08 +02:00
2020-07-13 20:34:04 +02:00
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'SM_SYS-6018R'
])
def test_supermicro_pizza(fixture):
dmi = parse(fixture)
server = SupermicroHost(dmi)
assert server.get_service_tag() == 'A177950X7709591'
assert server.is_blade() is False
2020-07-29 00:21:08 +02:00
2020-07-28 18:51:15 +02:00
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'QCT_X10E-9N'
])
def test_qct_x10(fixture):
dmi = parse(fixture)
server = QCTHost(dmi)
assert server.get_service_tag() == 'QTFCQ57140285'
2020-07-29 00:21:08 +02:00
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'unknown.txt'
])
def test_generic_host_service_tag(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
assert server.get_service_tag() == '42'
@parametrize_with_fixtures(
'dmidecode/', only_filenames=[
'unknown.txt'
])
def test_generic_host_product_name(fixture):
dmi = parse(fixture)
server = ServerBase(dmi)
assert server.get_product_name() == 'SR'