From 93514c5e595e30bd7f4f2c8259db3d40e41a24e5 Mon Sep 17 00:00:00 2001 From: Emilio Perez Date: Wed, 12 Jun 2024 15:48:58 +0100 Subject: [PATCH] tests: add tests related to Get Device GUID --- pyipmi/bmc.py | 6 ++++-- tests/msgs/test_bmc.py | 15 +++++++++++++++ tests/test_bmc.py | 10 +++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pyipmi/bmc.py b/pyipmi/bmc.py index b57916e..f961955 100644 --- a/pyipmi/bmc.py +++ b/pyipmi/bmc.py @@ -172,8 +172,10 @@ def _from_response(self, rsp): class DeviceGuid(State): def __str__(self): - return 'Device GUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-' \ - '%02x%02x%02x%02x%02x%02x' % tuple(reversed(self.device_guid)) + return 'Device GUID: %s' % self.device_guid_string def _from_response(self, rsp): self.device_guid = rsp.device_guid + self.device_guid_string = \ + '%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-' \ + '%02x%02x%02x%02x%02x%02x' % tuple(reversed(self.device_guid)) diff --git a/tests/msgs/test_bmc.py b/tests/msgs/test_bmc.py index fbdfa09..ecc9b9d 100644 --- a/tests/msgs/test_bmc.py +++ b/tests/msgs/test_bmc.py @@ -67,6 +67,21 @@ def test_getdeviceid_decode_valid_rsp_wo_aux(): assert m.product_id == 5310 +def test_getdeviceguid_decode_req(): + m = pyipmi.msgs.bmc.GetDeviceGuidReq() + decode_message(m, b'') + + +def test_getdeviceid_decode_valid_rsp(): + m = pyipmi.msgs.bmc.GetDeviceGuidRsp() + decode_message(m, + b'\x00\xff\xee\xdd\xcc\xbb\xaa\x99\x88\x77\x66\x55\x44\x33\x22\x11\x00') + assert m.completion_code == 0x00 + assert m.device_guid == array('B', [0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, + 0x99, 0x88,0x77, 0x66, 0x55, 0x44, + 0x33, 0x22, 0x11, 0x00]) + + def test_getselftestresults_decode_test_passed_rsp(): m = pyipmi.msgs.bmc.GetSelftestResultsRsp() decode_message(m, b'\x00\x55\x00') diff --git a/tests/test_bmc.py b/tests/test_bmc.py index e2140c1..a69bf4a 100644 --- a/tests/test_bmc.py +++ b/tests/test_bmc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from pyipmi.bmc import DeviceId, Watchdog +from pyipmi.bmc import DeviceId, DeviceGuid, Watchdog import pyipmi.msgs.bmc from pyipmi.msgs import decode_message @@ -47,3 +47,11 @@ def test_deviceid_object_with_aux(): device_id = DeviceId(msg) assert device_id.aux == [1, 2, 3, 4] + + +def test_deviceguid_object(): + m = pyipmi.msgs.bmc.GetDeviceGuidRsp() + decode_message(m, + b'\x00\xff\xee\xdd\xcc\xbb\xaa\x99\x88\x77\x66\x55\x44\x33\x22\x11\x00') + guid = DeviceGuid(m) + assert guid.device_guid_string == '00112233-4455-6677-8899-aabbccddeeff'