Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/understack-workflows/tests/test_bmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ def mock_creds(mocker):
return mock


def test_bmc_for_ip_address(mock_creds):
def test_bmc_for_ip_address(mock_creds, monkeypatch):
# The credential function above is overridden by the environment variable so
# make sure it is removed, so we are using the correct test credential and
# not a production one.
monkeypatch.delenv("BMC_MASTER", raising=False)
assert os.getenv("BMC_MASTER") is None

bmc = bmc_for_ip_address("1.2.3.4")

assert bmc.ip_address == "1.2.3.4"
assert bmc.url() == "https://1.2.3.4"
assert bmc.username == "root"
Expand Down
65 changes: 65 additions & 0 deletions python/understack-workflows/tests/test_bmc_bios.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from understack_workflows import bmc_bios


def test_update_dell_bios_settings_skips_patch_when_desired_values_are_pending(mocker):
bmc = mocker.Mock()
bmc.system_path = "/redfish/v1/Systems/System.Embedded.1"
bmc.redfish_request.side_effect = [
{
"Attributes": {
"PxeDev1EnDis": "Disabled",
"PxeDev1Interface": "NIC.Slot.1-1",
"HttpDev1EnDis": "Disabled",
"HttpDev1Interface": "NIC.Slot.1-1",
"HttpDev1TlsMode": "TLS",
"TimeZone": "Local",
"OS-BMC.1.AdminState": "Enabled",
"IPMILan.1.Enable": "Enabled",
}
},
{"Attributes": bmc_bios.required_bios_settings("NIC.Embedded.1-1-1")},
]
patch_bios_settings = mocker.patch.object(bmc_bios, "patch_bios_settings")

result = bmc_bios.update_dell_bios_settings(bmc, "NIC.Embedded.1-1-1")

assert result == {}
patch_bios_settings.assert_not_called()


def test_update_dell_bios_settings_only_patches_settings_not_already_pending(mocker):
bmc = mocker.Mock()
bmc.system_path = "/redfish/v1/Systems/System.Embedded.1"
bmc.redfish_request.side_effect = [
{
"Attributes": {
"PxeDev1EnDis": "Enabled",
"PxeDev1Interface": "NIC.Slot.1-1",
"HttpDev1EnDis": "Disabled",
"HttpDev1Interface": "NIC.Slot.1-1",
"HttpDev1TlsMode": "TLS",
"TimeZone": "UTC",
"OS-BMC.1.AdminState": "Enabled",
"IPMILan.1.Enable": "Disabled",
}
},
{
"Attributes": {
"PxeDev1EnDis": "Enabled",
"PxeDev1Interface": "NIC.Embedded.1-1-1",
"TimeZone": "UTC",
"IPMILan.1.Enable": "Disabled",
}
},
]
patch_bios_settings = mocker.patch.object(bmc_bios, "patch_bios_settings")

result = bmc_bios.update_dell_bios_settings(bmc, "NIC.Embedded.1-1-1")

assert result == {
"HttpDev1EnDis": "Enabled",
"HttpDev1Interface": "NIC.Embedded.1-1-1",
"HttpDev1TlsMode": "None",
"OS-BMC.1.AdminState": "Disabled",
}
patch_bios_settings.assert_called_once_with(bmc, result)
Loading
Loading