def test_get_cloudwatch_data_no_results(m_client, m_datetime): with open(os.path.join(module_path, "data", "cloudwatch_data_none.json")) as fh: response_data = json.loads(fh.read(), object_hook=datetime_parser) client = MagicMock() m_client.return_value = client client.get_metric_data.return_value = response_data m_datetime.utcnow.return_value = datetime(2020, 1, 1, 17, 00, tzinfo=timezone.utc) args = { "namespace": "AWS/ApplicationELB", "metric_name": "HTTPCode_ELB_504_Count", "dimension_name": "LoadBalancer", "dimension_value": "app/my_test_alb/0000000000000000", "period": 60, "duration": 300, "statistic": "Average", "unit": "Count", } response = get_metric_data(**args) assert response == 0 client.get_metric_data.assert_called_with( MetricDataQueries=[ { "Id": "m1", "MetricStat": { "Metric": { "Namespace": "AWS/ApplicationELB", "MetricName": "HTTPCode_ELB_504_Count", "Dimensions": [{ "Name": "LoadBalancer", "Value": "app/my_test_alb/0000000000000000", }], }, "Period": 60, "Stat": "Average", "Unit": "Count", }, "Label": "HTTPCode_ELB_504_Count", }, ], StartTime=datetime(2020, 1, 1, 16, 55, tzinfo=timezone.utc), EndTime=datetime(2020, 1, 1, 17, 0, tzinfo=timezone.utc), )
def test_get_cloudwatch_data_no_results(m_client, m_datetime): with open(os.path.join(module_path, 'data', 'cloudwatch_data_none.json'), 'r') as fh: response_data = json.loads(fh.read(), object_hook=datetime_parser) client = MagicMock() m_client.return_value = client client.get_metric_data.return_value = response_data m_datetime.utcnow.return_value = datetime(2020, 1, 1, 17, 00, tzinfo=timezone.utc) args = { 'namespace': 'AWS/ApplicationELB', 'metric_name': 'HTTPCode_ELB_504_Count', 'dimension_name': 'LoadBalancer', 'dimension_value': 'app/my_test_alb/0000000000000000', 'period': 60, 'duration': 300, 'statistic': 'Average', 'unit': 'Count' } response = get_metric_data(**args) assert response == 0 client.get_metric_data.assert_called_with( MetricDataQueries=[ { 'Id': 'm1', 'MetricStat': { 'Metric': { 'Namespace': 'AWS/ApplicationELB', 'MetricName': 'HTTPCode_ELB_504_Count', 'Dimensions': [{ 'Name': 'LoadBalancer', 'Value': 'app/my_test_alb/0000000000000000' }] }, 'Period': 60, 'Stat': 'Average', 'Unit': 'Count', }, 'Label': 'HTTPCode_ELB_504_Count', }, ], StartTime=datetime(2020, 1, 1, 16, 55, tzinfo=timezone.utc), EndTime=datetime(2020, 1, 1, 17, 0, tzinfo=timezone.utc))