Skip to content

Commit

Permalink
Update percentage handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ellation-mchau committed Jun 22, 2018
1 parent 32c86f2 commit 77a89f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ses_account_monitor/services/cloudwatch_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_last_metric(metric):
last_index = metric['Timestamps'].index(last_ts)
last_value = metric['Values'][last_index]

return (metric['Label'], last_value * 100.0, last_ts.astimezone(timezone.utc).isoformat())
return (metric['Label'], last_value, last_ts.astimezone(timezone.utc).isoformat())


class CloudWatchService(object):
Expand Down
8 changes: 4 additions & 4 deletions test/services/test_cloudwatch_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def test_get_ses_account_reputation_metric_data_results(client,


def test_build_ses_account_reputation_metrics(service, build_metric_data_results):
metric_data_results = build_metric_data_results(0.05, 0.1)
metric_data_results = build_metric_data_results(5.0, 0.1)
result = service.build_ses_account_reputation_metrics(metric_data_results)

assert result.critical == [('Complaint Rate', 10.0, 0.04, '2018-06-17T02:11:25.787402+00:00')]
assert result.critical == [('Complaint Rate', 0.1, 0.04, '2018-06-17T02:11:25.787402+00:00')]
assert result.ok == []
assert result.warning == [('Bounce Rate', 5.0, 5.0, '2018-06-17T02:11:25.787402+00:00')]

Expand All @@ -158,6 +158,6 @@ def test_get_ses_account_reputation_metrics(client,
with stubber:
result = service.get_ses_account_reputation_metrics(target_datetime=end_datetime)
assert result.critical == []
assert result.ok == [('Bounce Rate', 3.0, 5.0, '2018-06-17T02:11:25.787402+00:00'),
('Complaint Rate', 0.001, 0.01, '2018-06-17T02:11:25.787402+00:00')]
assert result.ok == [('Bounce Rate', 0.03, 5.0, '2018-06-17T02:11:25.787402+00:00'),
('Complaint Rate', 0.00001, 0.01, '2018-06-17T02:11:25.787402+00:00')]
assert result.warning == []
8 changes: 4 additions & 4 deletions test/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def metric_data_results_response_critical(end_datetime):
end_datetime,
],
'Values': [
0.05
5.0
],
'StatusCode': 'Complete',
},
Expand All @@ -107,7 +107,7 @@ def metric_data_results_response_critical(end_datetime):
end_datetime
],
'Values': [
0.99
99.0
]
}
],
Expand All @@ -126,7 +126,7 @@ def metric_data_results_response_warning(end_datetime):
end_datetime,
],
'Values': [
0.054
5.23994
],
'StatusCode': 'Complete',
},
Expand Down Expand Up @@ -445,7 +445,7 @@ def test_handle_ses_reputation_warning(monitor, end_datetime, metric_data_result
'value': 'ALERT'},
{'short': True,
'title': 'Bounce Rate / Threshold',
'value': '5.40% / 5.00%'},
'value': '5.24% / 5.00%'},
{'short': True,
'title': 'Bounce Rate Time',
'value': '2018-06-17T02:11:25.787402+00:00'},
Expand Down

0 comments on commit 77a89f2

Please sign in to comment.