Fix:CloudWatch List metrics with dimensions (#3461)
* Fix:CloudWatch List metrics with dimensions * Fix:CloudWatch List metrics with dimensions * Fixed new cases and added more tests Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
parent
8a95878a81
commit
54e296eb53
2 changed files with 146 additions and 7 deletions
|
|
@ -349,6 +349,123 @@ def test_get_metric_statistics():
|
|||
datapoint["Sum"].should.equal(1.5)
|
||||
|
||||
|
||||
@mock_cloudwatch
|
||||
def test_duplicate_put_metric_data():
|
||||
conn = boto3.client("cloudwatch", region_name="us-east-1")
|
||||
utc_now = datetime.now(tz=pytz.utc)
|
||||
|
||||
conn.put_metric_data(
|
||||
Namespace="tester",
|
||||
MetricData=[
|
||||
dict(
|
||||
MetricName="metric",
|
||||
Dimensions=[{"Name": "Name", "Value": "B"}],
|
||||
Value=1.5,
|
||||
Timestamp=utc_now,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
result = conn.list_metrics(
|
||||
Namespace="tester", Dimensions=[{"Name": "Name", "Value": "B"}]
|
||||
)["Metrics"]
|
||||
len(result).should.equal(1)
|
||||
|
||||
conn.put_metric_data(
|
||||
Namespace="tester",
|
||||
MetricData=[
|
||||
dict(
|
||||
MetricName="metric",
|
||||
Dimensions=[{"Name": "Name", "Value": "B"}],
|
||||
Value=1.5,
|
||||
Timestamp=utc_now,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
result = conn.list_metrics(
|
||||
Namespace="tester", Dimensions=[{"Name": "Name", "Value": "B"}]
|
||||
)["Metrics"]
|
||||
len(result).should.equal(1)
|
||||
|
||||
conn.put_metric_data(
|
||||
Namespace="tester",
|
||||
MetricData=[
|
||||
dict(
|
||||
MetricName="metric",
|
||||
Dimensions=[{"Name": "Name", "Value": "B"}],
|
||||
Value=1.5,
|
||||
Timestamp=utc_now,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
result = conn.list_metrics(
|
||||
Namespace="tester", Dimensions=[{"Name": "Name", "Value": "B"}]
|
||||
)["Metrics"]
|
||||
result.should.equal(
|
||||
[
|
||||
{
|
||||
"Namespace": "tester",
|
||||
"MetricName": "metric",
|
||||
"Dimensions": [{"Name": "Name", "Value": "B"}],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
conn.put_metric_data(
|
||||
Namespace="tester",
|
||||
MetricData=[
|
||||
dict(
|
||||
MetricName="metric",
|
||||
Dimensions=[
|
||||
{"Name": "Name", "Value": "B"},
|
||||
{"Name": "Name", "Value": "C"},
|
||||
],
|
||||
Value=1.5,
|
||||
Timestamp=utc_now,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
result = conn.list_metrics(
|
||||
Namespace="tester", Dimensions=[{"Name": "Name", "Value": "B"}]
|
||||
)["Metrics"]
|
||||
result.should.equal(
|
||||
[
|
||||
{
|
||||
"Namespace": "tester",
|
||||
"MetricName": "metric",
|
||||
"Dimensions": [{"Name": "Name", "Value": "B"}],
|
||||
},
|
||||
{
|
||||
"Namespace": "tester",
|
||||
"MetricName": "metric",
|
||||
"Dimensions": [
|
||||
{"Name": "Name", "Value": "B"},
|
||||
{"Name": "Name", "Value": "C"},
|
||||
],
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
result = conn.list_metrics(
|
||||
Namespace="tester", Dimensions=[{"Name": "Name", "Value": "C"}]
|
||||
)["Metrics"]
|
||||
result.should.equal(
|
||||
[
|
||||
{
|
||||
"Namespace": "tester",
|
||||
"MetricName": "metric",
|
||||
"Dimensions": [
|
||||
{"Name": "Name", "Value": "B"},
|
||||
{"Name": "Name", "Value": "C"},
|
||||
],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@mock_cloudwatch
|
||||
@freeze_time("2020-02-10 18:44:05")
|
||||
def test_custom_timestamp():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue