Skip to content

Commit 5424c78

Browse files
committed
add test for cloud_watch_alarm.py
1 parent e7a91b0 commit 5424c78

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/unit/event_handler/_async_execution/_routes/test_cloud_watch_alarm.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,56 @@ def test_constructor_error(self):
1414
with pytest.raises(ValueError):
1515
CloudWatchAlarmRoute(func=None)
1616

17+
@pytest.mark.parametrize(
18+
"option_constructor, option_func, expected",
19+
[
20+
(
21+
{"func": None, "arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
22+
{"arn": None},
23+
False,
24+
),
25+
(
26+
{"func": None, "arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
27+
{"arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
28+
True,
29+
),
30+
(
31+
{"func": None, "arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.MainV2"},
32+
{"arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
33+
False,
34+
),
35+
(
36+
{"func": None, "alarm_name": "SuppressionDemo.Main"},
37+
{"arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
38+
False,
39+
),
40+
],
41+
)
42+
def test_is_target_with_arn(self, option_constructor, option_func, expected):
43+
route = CloudWatchAlarmRoute(**option_constructor)
44+
actual = route.is_target_with_arn(**option_func)
45+
assert actual == expected
46+
47+
@pytest.mark.parametrize(
48+
"option_constructor, option_func, expected",
49+
[
50+
({"func": None, "alarm_name": "CompositeDemo.Main"}, {"alarm_name": None}, False),
51+
({"func": None, "alarm_name": "CompositeDemo.Main"}, {"alarm_name": "CompositeDemo.Main"}, True),
52+
({"func": None, "alarm_name": "CompositeDemo.MainV2"}, {"alarm_name": "CompositeDemo.Main"}, False),
53+
({"func": None, "alarm_name_prefix": "CompositeDemo.M"}, {"alarm_name": "CompositeDemo.Main"}, True),
54+
({"func": None, "alarm_name_prefix": "Main"}, {"alarm_name": "CompositeDemo.Main"}, False),
55+
(
56+
{"func": None, "arn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:SuppressionDemo.Main"},
57+
{"alarm_name": "CompositeDemo.Main"},
58+
False,
59+
),
60+
],
61+
)
62+
def test_is_target_with_alarm_name(self, option_constructor, option_func, expected):
63+
route = CloudWatchAlarmRoute(**option_constructor)
64+
actual = route.is_target_with_alarm_name(**option_func)
65+
assert actual == expected
66+
1767
@pytest.mark.parametrize(
1868
"event_name, option_constructor",
1969
[

0 commit comments

Comments
 (0)