Add test for handler signature
This commit is contained in:
parent
831ae22872
commit
24683c8954
1 changed files with 24 additions and 0 deletions
|
@ -51,6 +51,19 @@ class StubHandler2(EventHandler):
|
|||
self.handler_called = True
|
||||
|
||||
|
||||
class WrongHandler(EventHandler):
|
||||
|
||||
def __init__(self) -> None:
|
||||
handler_map = {
|
||||
'myeventname': self._handler_wrong,
|
||||
}
|
||||
super().__init__(handler_map=handler_map)
|
||||
|
||||
def _handler_wrong(
|
||||
self,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
class TestProcessor(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
|
@ -58,6 +71,17 @@ class TestProcessor(unittest.TestCase):
|
|||
*args,
|
||||
)
|
||||
|
||||
def test_handler_wrong_signature(self) -> None:
|
||||
handler = WrongHandler()
|
||||
mock_event = {
|
||||
'_name': 'myeventname',
|
||||
'_timestamp': 0,
|
||||
'cpu_id': 0,
|
||||
}
|
||||
processor = Processor(handler)
|
||||
with self.assertRaises(TypeError):
|
||||
processor.process([mock_event])
|
||||
|
||||
def test_handler_method_with_merge(self) -> None:
|
||||
handler1 = StubHandler1()
|
||||
handler2 = StubHandler2()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue