Files
napalm-redfish/tests/parsers/test_service_root.py
T
Christian Manivong 09029ca0a4 style: ruff format and the lint rules of the driver standard
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM
driver uses (E, F, I, UP, B at line length 100, Python 3.10). Mapping and
Iterable come from collections.abc, imports are sorted. What ruff cannot
fix comes in the next commit.
2026-10-23 08:39:45 +02:00

49 lines
1.8 KiB
Python

from napalm_redfish.parsers import parse_service_root
def test_service_root(rackmount):
root = parse_service_root(rackmount("/redfish/v1/"))
assert root["redfish_version"] == "1.15.0"
assert root["uuid"] == "92384634-2938-2342-8820-489239905423"
assert root["name"] == "Root Service"
# Vendor and Product only exist from ServiceRoot 1.5 on, and this mockup has neither.
assert root["vendor"] is None
assert root["product"] is None
assert root["oem_vendors"] == []
def test_service_root_links(rackmount):
links = parse_service_root(rackmount("/redfish/v1/"))["links"]
assert links["Systems"] == "/redfish/v1/Systems"
assert links["Chassis"] == "/redfish/v1/Chassis"
assert links["Managers"] == "/redfish/v1/Managers"
assert links["AccountService"] == "/redfish/v1/AccountService"
assert links["UpdateService"] == "/redfish/v1/UpdateService"
assert links["SessionService"] == "/redfish/v1/SessionService"
# Links.Sessions is where the session login goes.
assert links["Sessions"] == "/redfish/v1/SessionService/Sessions"
assert "@odata.id" not in links
def test_service_root_vendor_and_oem():
root = parse_service_root(
{
"RedfishVersion": "1.0.1",
"Vendor": "Supermicro",
"Product": "X10DRL-i",
"Oem": {"Supermicro": {"@odata.type": "#SmcServiceRoot"}},
"Systems": {"@odata.id": "/redfish/v1/Systems"},
}
)
assert root["vendor"] == "Supermicro"
assert root["product"] == "X10DRL-i"
assert root["oem_vendors"] == ["Supermicro"]
assert root["uuid"] is None
assert root["links"] == {"Systems": "/redfish/v1/Systems"}
def test_service_root_empty():
root = parse_service_root({})
assert root["redfish_version"] is None
assert root["links"] == {}