parse 'ActionsEnabled' as boolean for describe-alarms (#5313)
This commit is contained in:
parent
5ece8a816c
commit
7658051594
@ -76,7 +76,7 @@ class CloudWatchResponse(BaseResponse):
|
|||||||
dimensions = self._get_list_prefix("Dimensions.member")
|
dimensions = self._get_list_prefix("Dimensions.member")
|
||||||
alarm_actions = self._get_multi_param("AlarmActions.member")
|
alarm_actions = self._get_multi_param("AlarmActions.member")
|
||||||
ok_actions = self._get_multi_param("OKActions.member")
|
ok_actions = self._get_multi_param("OKActions.member")
|
||||||
actions_enabled = self._get_param("ActionsEnabled")
|
actions_enabled = self._get_bool_param("ActionsEnabled")
|
||||||
insufficient_data_actions = self._get_multi_param(
|
insufficient_data_actions = self._get_multi_param(
|
||||||
"InsufficientDataActions.member"
|
"InsufficientDataActions.member"
|
||||||
)
|
)
|
||||||
@ -354,7 +354,7 @@ DESCRIBE_ALARMS_TEMPLATE = """<DescribeAlarmsResponse xmlns="http://monitoring.a
|
|||||||
<{{tag_name}}>
|
<{{tag_name}}>
|
||||||
{% for alarm in alarms %}
|
{% for alarm in alarms %}
|
||||||
<member>
|
<member>
|
||||||
<ActionsEnabled>{{ alarm.actions_enabled }}</ActionsEnabled>
|
<ActionsEnabled>{{ "true" if alarm.actions_enabled else "false" }}</ActionsEnabled>
|
||||||
<AlarmActions>
|
<AlarmActions>
|
||||||
{% for action in alarm.alarm_actions %}
|
{% for action in alarm.alarm_actions %}
|
||||||
<member>{{ action }}</member>
|
<member>{{ action }}</member>
|
||||||
@ -480,7 +480,7 @@ DESCRIBE_METRIC_ALARMS_TEMPLATE = """<DescribeAlarmsForMetricResponse xmlns="htt
|
|||||||
<MetricAlarms>
|
<MetricAlarms>
|
||||||
{% for alarm in alarms %}
|
{% for alarm in alarms %}
|
||||||
<member>
|
<member>
|
||||||
<ActionsEnabled>{{ alarm.actions_enabled }}</ActionsEnabled>
|
<ActionsEnabled>{{ "true" if alarm.actions_enabled else "false" }}</ActionsEnabled>
|
||||||
<AlarmActions>
|
<AlarmActions>
|
||||||
{% for action in alarm.alarm_actions %}
|
{% for action in alarm.alarm_actions %}
|
||||||
<member>{{ action }}</member>
|
<member>{{ action }}</member>
|
||||||
|
@ -50,6 +50,8 @@ def test_create_alarm():
|
|||||||
alarm.should.have.key("AlarmArn").equal(
|
alarm.should.have.key("AlarmArn").equal(
|
||||||
"arn:aws:cloudwatch:{}:{}:alarm:{}".format(region, ACCOUNT_ID, name)
|
"arn:aws:cloudwatch:{}:{}:alarm:{}".format(region, ACCOUNT_ID, name)
|
||||||
)
|
)
|
||||||
|
# default value should be True
|
||||||
|
alarm.should.have.key("ActionsEnabled").equal(True)
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudwatch
|
@mock_cloudwatch
|
||||||
@ -111,8 +113,9 @@ def test_describe_alarms_for_metric():
|
|||||||
)
|
)
|
||||||
alarms = conn.describe_alarms_for_metric(MetricName="cpu", Namespace="blah")
|
alarms = conn.describe_alarms_for_metric(MetricName="cpu", Namespace="blah")
|
||||||
alarms.get("MetricAlarms").should.have.length_of(1)
|
alarms.get("MetricAlarms").should.have.length_of(1)
|
||||||
|
alarm = alarms.get("MetricAlarms")[0]
|
||||||
assert "testalarm1" in alarms.get("MetricAlarms")[0].get("AlarmArn")
|
assert "testalarm1" in alarm.get("AlarmArn")
|
||||||
|
alarm.should.have.key("ActionsEnabled").equal(True)
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudwatch
|
@mock_cloudwatch
|
||||||
@ -127,7 +130,7 @@ def test_describe_alarms():
|
|||||||
Statistic="Average",
|
Statistic="Average",
|
||||||
Threshold=2,
|
Threshold=2,
|
||||||
ComparisonOperator="GreaterThanThreshold",
|
ComparisonOperator="GreaterThanThreshold",
|
||||||
ActionsEnabled=True,
|
ActionsEnabled=False,
|
||||||
)
|
)
|
||||||
metric_data_queries = [
|
metric_data_queries = [
|
||||||
{
|
{
|
||||||
@ -190,6 +193,7 @@ def test_describe_alarms():
|
|||||||
single_metric_alarm["Statistic"].should.equal("Average")
|
single_metric_alarm["Statistic"].should.equal("Average")
|
||||||
single_metric_alarm["ComparisonOperator"].should.equal("GreaterThanThreshold")
|
single_metric_alarm["ComparisonOperator"].should.equal("GreaterThanThreshold")
|
||||||
single_metric_alarm["Threshold"].should.equal(2)
|
single_metric_alarm["Threshold"].should.equal(2)
|
||||||
|
single_metric_alarm["ActionsEnabled"].should.equal(False)
|
||||||
|
|
||||||
multiple_metric_alarm.shouldnt.have.property("MetricName")
|
multiple_metric_alarm.shouldnt.have.property("MetricName")
|
||||||
multiple_metric_alarm["EvaluationPeriods"].should.equal(1)
|
multiple_metric_alarm["EvaluationPeriods"].should.equal(1)
|
||||||
@ -197,6 +201,7 @@ def test_describe_alarms():
|
|||||||
multiple_metric_alarm["Metrics"].should.equal(metric_data_queries)
|
multiple_metric_alarm["Metrics"].should.equal(metric_data_queries)
|
||||||
multiple_metric_alarm["ComparisonOperator"].should.equal("GreaterThanThreshold")
|
multiple_metric_alarm["ComparisonOperator"].should.equal("GreaterThanThreshold")
|
||||||
multiple_metric_alarm["Threshold"].should.equal(1.0)
|
multiple_metric_alarm["Threshold"].should.equal(1.0)
|
||||||
|
multiple_metric_alarm["ActionsEnabled"].should.equal(True)
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudwatch
|
@mock_cloudwatch
|
||||||
@ -243,7 +248,7 @@ def test_alarm_state():
|
|||||||
len(resp["MetricAlarms"]).should.equal(1)
|
len(resp["MetricAlarms"]).should.equal(1)
|
||||||
resp["MetricAlarms"][0]["AlarmName"].should.equal("testalarm2")
|
resp["MetricAlarms"][0]["AlarmName"].should.equal("testalarm2")
|
||||||
resp["MetricAlarms"][0]["StateValue"].should.equal("OK")
|
resp["MetricAlarms"][0]["StateValue"].should.equal("OK")
|
||||||
resp["MetricAlarms"][0]["ActionsEnabled"].should.equal(False)
|
resp["MetricAlarms"][0]["ActionsEnabled"].should.equal(True)
|
||||||
|
|
||||||
# Just for sanity
|
# Just for sanity
|
||||||
resp = client.describe_alarms()
|
resp = client.describe_alarms()
|
||||||
|
Loading…
Reference in New Issue
Block a user