@@ -898,3 +898,30 @@ def lambda_handler(evt, ctx):
898
898
# THEN we should have default dimensions in both outputs
899
899
assert "environment" in first_invocation
900
900
assert "environment" in second_invocation
901
+
902
+
903
+ def test_metrics_reuse_dimension_set (metric , dimension , namespace ):
904
+ # GIVEN Metrics is initialized with a metric and dimension
905
+ my_metrics = Metrics (namespace = namespace )
906
+ my_metrics .add_dimension (** dimension )
907
+ my_metrics .add_metric (** metric )
908
+
909
+ # WHEN Metrics is initialized one more time
910
+ my_metrics_2 = Metrics (namespace = namespace )
911
+
912
+ # THEN both class instances should have the same dimension set
913
+ assert my_metrics_2 .dimension_set == my_metrics .dimension_set
914
+
915
+
916
+ def test_metrics_reuse_metadata_set (metric , dimension , namespace ):
917
+ # GIVEN Metrics is initialized with a metric, dimension, and metadata
918
+ my_metrics = Metrics (namespace = namespace )
919
+ my_metrics .add_dimension (** dimension )
920
+ my_metrics .add_metric (** metric )
921
+ my_metrics .add_metadata (key = "meta" , value = "data" )
922
+
923
+ # WHEN Metrics is initialized one more time
924
+ my_metrics_2 = Metrics (namespace = namespace )
925
+
926
+ # THEN both class instances should have the same metadata set
927
+ assert my_metrics_2 .metadata_set == my_metrics .metadata_set
0 commit comments