Skip to content

Commit b0e76e8

Browse files
improv(metrics): Using MAX_DIMENSIONS constant in test file to avoid changes in future
1 parent 17fd12f commit b0e76e8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/functional/test_metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aws_lambda_powertools import Metrics, single_metric
99
from aws_lambda_powertools.metrics import MetricUnit, MetricUnitError, MetricValueError, SchemaValidationError
1010
from aws_lambda_powertools.metrics import metrics as metrics_global
11-
from aws_lambda_powertools.metrics.base import MetricManager
11+
from aws_lambda_powertools.metrics.base import MAX_DIMENSIONS, MetricManager
1212

1313

1414
@pytest.fixture(scope="function", autouse=True)
@@ -321,7 +321,7 @@ def test_schema_no_metrics(service, namespace):
321321

322322
def test_exceed_number_of_dimensions(metric, namespace):
323323
# GIVEN we have more dimensions than CloudWatch supports (N+1)
324-
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(31)]
324+
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(MAX_DIMENSIONS + 2)]
325325

326326
# WHEN we attempt to serialize them into a valid EMF object
327327
# THEN it should fail validation and raise SchemaValidationError
@@ -334,7 +334,7 @@ def test_exceed_number_of_dimensions(metric, namespace):
334334
def test_exceed_number_of_dimensions_with_service(metric, namespace, monkeypatch):
335335
# GIVEN we have service set and add more dimensions than CloudWatch supports (N-1)
336336
monkeypatch.setenv("POWERTOOLS_SERVICE_NAME", "test_service")
337-
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(29)]
337+
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(MAX_DIMENSIONS)]
338338

339339
# WHEN we attempt to serialize them into a valid EMF object
340340
# THEN it should fail validation and raise SchemaValidationError

0 commit comments

Comments
 (0)