Skip to content

Commit 3e5b73c

Browse files
author
Alexander Melnyk
committed
Merge branch 'develop' of github.com:awslabs/aws-lambda-powertools-python into develop
2 parents b67020b + 5d5e7b8 commit 3e5b73c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/functional/test_metrics.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,20 @@ def test_schema_no_metrics(service, namespace):
319319
my_metrics.serialize_metric_set()
320320

321321

322-
def test_exceed_number_of_dimensions(metric, namespace, monkeypatch):
323-
# GIVEN we we have more dimensions than CloudWatch supports
324-
# and that service dimension is injected like a user-defined dimension (N+1)
322+
def test_exceed_number_of_dimensions(metric, namespace):
323+
# GIVEN we have more dimensions than CloudWatch supports
324+
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(11)]
325+
326+
# WHEN we attempt to serialize them into a valid EMF object
327+
# THEN it should fail validation and raise SchemaValidationError
328+
with pytest.raises(SchemaValidationError, match="Maximum number of dimensions exceeded.*"):
329+
with single_metric(**metric, namespace=namespace) as my_metric:
330+
for dimension in dimensions:
331+
my_metric.add_dimension(**dimension)
332+
333+
334+
def test_exceed_number_of_dimensions_with_service(metric, namespace, monkeypatch):
335+
# GIVEN we have service set and add more dimensions than CloudWatch supports (N+1)
325336
monkeypatch.setenv("POWERTOOLS_SERVICE_NAME", "test_service")
326337
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(9)]
327338

0 commit comments

Comments
 (0)