Skip to content

Commit 87b6937

Browse files
committed
Added tests for block action serialization
1 parent 183cfe2 commit 87b6937

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/components/test_action.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@ def test_action_to_dict_quit_game(self):
450450
assert action_dict["action_type"] == str(action.type)
451451
assert len(action_dict["parameters"]) == 0
452452

453+
def test_action_to_dict_block_ip(self):
454+
action = Action(
455+
action_type=ActionType.BlockIP,
456+
parameters={
457+
"target_host": IP("192.168.1.0"),
458+
"source_host": IP("192.168.1.1"),
459+
"blocked_ip": IP("1.1.1.1")
460+
}
461+
)
462+
action_dict = action.as_dict
463+
new_action = Action.from_dict(action_dict)
464+
assert action == new_action
465+
assert action_dict["action_type"] == str(action.type)
466+
assert action_dict["parameters"]["target_host"] == {'ip': '192.168.1.0'}
467+
assert action_dict["parameters"]["source_host"] == {'ip': '192.168.1.1'}
468+
assert action_dict["parameters"]["blocked_ip"] == {'ip': '1.1.1.1'}
469+
453470
def test_action_type_eq_unsupported(self):
454471
"""Test ActionType equality with unsupported type"""
455472
assert (ActionType.FindData == 123) is False

0 commit comments

Comments
 (0)