@@ -38,7 +38,8 @@ def test_verify(mocker):
3838 'AlarmName' : 'test_alarm' ,
3939 'AlarmDesc' : 'alarm_desc' ,
4040 'AlarmThreshold' : 'alarm_threshold' ,
41- 'LogGroupName' : 'test_log'
41+ 'LogGroupName' : 'test_log' ,
42+ 'TopicArn' : 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
4243 }
4344 context = {}
4445 mocker .patch ('CreateLogMetricFilterAndAlarm.put_metric_filter' )
@@ -47,7 +48,7 @@ def test_verify(mocker):
4748 metric_alarm_spy = mocker .spy (logMetricAlarm , 'put_metric_alarm' )
4849 logMetricAlarm .verify (event , context )
4950 metric_filter_spy .assert_called_once_with ('test_log' , 'test_filter' , 'test_pattern' , 'test_metric' , 'test_metricnamespace' , 'test_metric_value' )
50- metric_alarm_spy .assert_called_once_with ('test_alarm' , 'alarm_desc' , 'alarm_threshold' , 'test_metric' , 'test_metricnamespace' )
51+ metric_alarm_spy .assert_called_once_with ('test_alarm' , 'alarm_desc' , 'alarm_threshold' , 'test_metric' , 'test_metricnamespace' , 'arn:aws:sns:us-east-1:111111111111:test-topic-name' )
5152
5253
5354def test_put_metric_filter_pass (mocker ):
@@ -60,7 +61,8 @@ def test_put_metric_filter_pass(mocker):
6061 'AlarmName' : 'test_alarm' ,
6162 'AlarmDesc' : 'alarm_desc' ,
6263 'AlarmThreshold' : 'alarm_threshold' ,
63- 'LogGroupName' : 'test_log'
64+ 'LogGroupName' : 'test_log' ,
65+ 'TopicArn' : 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
6466 }
6567
6668 BOTO_CONFIG = Config (
@@ -109,7 +111,8 @@ def test_put_metric_filter_error(mocker):
109111 'AlarmName' : 'test_alarm' ,
110112 'AlarmDesc' : 'alarm_desc' ,
111113 'AlarmThreshold' : 'alarm_threshold' ,
112- 'LogGroupName' : 'test_log'
114+ 'LogGroupName' : 'test_log' ,
115+ 'TopicArn' : 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
113116 }
114117
115118 BOTO_CONFIG = Config (
@@ -146,7 +149,8 @@ def test_put_metric_alarm(mocker):
146149 'AlarmName' : 'test_alarm' ,
147150 'AlarmDesc' : 'alarm_desc' ,
148151 'AlarmThreshold' : 1 ,
149- 'LogGroupName' : 'test_log'
152+ 'LogGroupName' : 'test_log' ,
153+ 'TopicArn' : 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
150154 }
151155
152156 BOTO_CONFIG = Config (
@@ -164,7 +168,13 @@ def test_put_metric_alarm(mocker):
164168 {
165169 'AlarmName' : event ['AlarmName' ],
166170 'AlarmDescription' : event ['AlarmDesc' ],
167- 'ActionsEnabled' : False ,
171+ 'ActionsEnabled' : True ,
172+ 'OKActions' : [
173+ 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
174+ ],
175+ 'AlarmActions' : [
176+ 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
177+ ],
168178 'MetricName' : event ['MetricName' ],
169179 'Namespace' : event ['MetricNamespace' ],
170180 'Statistic' : 'Sum' ,
@@ -179,7 +189,7 @@ def test_put_metric_alarm(mocker):
179189 mocker .patch ('CreateLogMetricFilterAndAlarm.get_service_client' , return_value = cloudwatch )
180190 logMetricAlarm .put_metric_alarm (
181191 event ['AlarmName' ], event ['AlarmDesc' ], event ['AlarmThreshold' ],
182- event ['MetricName' ], event ['MetricNamespace' ]
192+ event ['MetricName' ], event ['MetricNamespace' ], event [ 'TopicArn' ]
183193 )
184194 assert cloudwatch_stubber .assert_no_pending_responses () is None
185195 cloudwatch_stubber .deactivate ()
@@ -195,7 +205,8 @@ def test_put_metric_alarm_error(mocker):
195205 'AlarmName' : 'test_alarm' ,
196206 'AlarmDesc' : 'alarm_desc' ,
197207 'AlarmThreshold' : 1 ,
198- 'LogGroupName' : 'test_log'
208+ 'LogGroupName' : 'test_log' ,
209+ 'TopicArn' : 'arn:aws:sns:us-east-1:111111111111:test-topic-name'
199210 }
200211
201212 BOTO_CONFIG = Config (
@@ -217,7 +228,7 @@ def test_put_metric_alarm_error(mocker):
217228 with pytest .raises (SystemExit ) as pytest_wrapped_exception :
218229 logMetricAlarm .put_metric_alarm (
219230 event ['AlarmName' ], event ['AlarmDesc' ], event ['AlarmThreshold' ],
220- event ['MetricName' ], event ['MetricNamespace' ]
231+ event ['MetricName' ], event ['MetricNamespace' ], event [ 'TopicArn' ]
221232 )
222233 assert pytest_wrapped_exception .type == SystemExit
223234 cloudwatch_stubber .deactivate ()
0 commit comments