mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-15 02:27:17 +00:00
Fix event handler pytest.raises test cases
This commit is contained in:
parent
0549c5e4c8
commit
9e49a93df3
@ -89,7 +89,7 @@ def test_build_from_object(test_keys, test_msg):
|
|||||||
assert mock_eh.connector is eh.connector
|
assert mock_eh.connector is eh.connector
|
||||||
with pytest.raises(RuntimeError) as err:
|
with pytest.raises(RuntimeError) as err:
|
||||||
eh.connector.simulate_message(test_msg)
|
eh.connector.simulate_message(test_msg)
|
||||||
msg, keys = err.args
|
msg, keys = err.value.args
|
||||||
assert msg == test_msg
|
assert msg == test_msg
|
||||||
assert keys == test_keys
|
assert keys == test_keys
|
||||||
assert not mock_eh.cleaned_up
|
assert not mock_eh.cleaned_up
|
||||||
@ -119,16 +119,15 @@ def test_build_from_simple_object(test_keys, test_msg):
|
|||||||
class SimpleMockEventHandler:
|
class SimpleMockEventHandler:
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def handle_event(self, message, connector):
|
def handle_event(self, message, connector):
|
||||||
raise RuntimeError(message, connector)
|
raise RuntimeError(message)
|
||||||
|
|
||||||
mock_eh = SimpleMockEventHandler()
|
mock_eh = SimpleMockEventHandler()
|
||||||
eh = MockEventHandlerFactory().build(mock_eh, keys=test_keys)
|
eh = MockEventHandlerFactory().build(mock_eh, keys=test_keys)
|
||||||
|
|
||||||
with pytest.raises(RuntimeError) as err:
|
with pytest.raises(RuntimeError) as err:
|
||||||
eh.connector.simulate_message(test_msg)
|
eh.connector.simulate_message(test_msg)
|
||||||
msg, keys = err.args
|
msg = err.value.args[0]
|
||||||
assert msg == test_msg
|
assert msg == test_msg
|
||||||
assert keys == test_keys
|
|
||||||
|
|
||||||
|
|
||||||
def test_build_from_callable(test_keys, test_msg):
|
def test_build_from_callable(test_keys, test_msg):
|
||||||
@ -156,7 +155,7 @@ def test_build_from_function(test_keys, test_msg):
|
|||||||
assert eh.connector.keys == test_keys
|
assert eh.connector.keys == test_keys
|
||||||
with pytest.raises(RuntimeError) as err:
|
with pytest.raises(RuntimeError) as err:
|
||||||
eh.connector.simulate_message(test_msg)
|
eh.connector.simulate_message(test_msg)
|
||||||
msg, keys = err.args
|
msg, keys = err.value.args
|
||||||
assert msg == test_msg
|
assert msg == test_msg
|
||||||
assert keys == test_keys
|
assert keys == test_keys
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user