From cf7b27f6d21448614eb82d12a3609dbd24e7a6cf Mon Sep 17 00:00:00 2001 From: Heiko Thiery Date: Tue, 17 Dec 2024 09:16:42 +0100 Subject: [PATCH] tests: add event tests Signed-off-by: Heiko Thiery --- tests/test_event.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/test_event.py diff --git a/tests/test_event.py b/tests/test_event.py new file mode 100644 index 0000000..13272f8 --- /dev/null +++ b/tests/test_event.py @@ -0,0 +1,38 @@ +from unittest.mock import MagicMock + +from pyipmi import interfaces, create_connection +from pyipmi.msgs.event import (SetEventReceiverRsp, GetEventReceiverRsp) + + +class TestEvent(object): + + def setup_method(self): + self.mock_send_recv = MagicMock() + + interface = interfaces.create_interface('mock') + self.ipmi = create_connection(interface) + self.ipmi.send_message = self.mock_send_recv + + def test_set_event_receiver(self): + + rsp = SetEventReceiverRsp() + rsp.completion_code = 0 + self.mock_send_recv.return_value = rsp + + self.ipmi.set_event_receiver(ipmb_address=0xb0, lun=1) + args, _ = self.mock_send_recv.call_args + req = args[0] + assert req.event_receiver.ipmb_i2c_slave_address == 0xb0 + assert req.event_receiver.lun == 1 + + def test_get_event_receiver(self): + + rsp = GetEventReceiverRsp() + rsp.completion_code = 0 + rsp.event_receiver.ipmb_i2c_slave_address = 0xc0 + rsp.event_receiver.lun = 2 + self.mock_send_recv.return_value = rsp + + (addr, lun) = self.ipmi.get_event_receiver() + assert addr == 0xc0 + assert lun == 2