Skip to content

Commit

Permalink
tests: add tests related to Get Device GUID
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilioPeJu committed Jun 12, 2024
1 parent 2ab3693 commit 93514c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pyipmi/bmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
15 changes: 15 additions & 0 deletions tests/msgs/test_bmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 9 additions & 1 deletion tests/test_bmc.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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'

0 comments on commit 93514c5

Please sign in to comment.