@@ -135,6 +135,8 @@ def test_prometheus_minimal_config_empty_extra_args(self):
135135 expected_output ['metric_one' ]['groupby' ].append ('project_id' )
136136 expected_output ['metric_one' ]['extra_args' ] = {
137137 'aggregation_method' : 'max' ,
138+ 'query_prefix' : '' ,
139+ 'query_suffix' : '' ,
138140 }
139141 self .assertEqual (
140142 collector .prometheus .PrometheusCollector .check_configuration (data ),
@@ -147,6 +149,8 @@ def test_prometheus_minimal_config_no_extra_args(self):
147149 expected_output ['metric_one' ]['groupby' ].append ('project_id' )
148150 expected_output ['metric_one' ]['extra_args' ] = {
149151 'aggregation_method' : 'max' ,
152+ 'query_prefix' : '' ,
153+ 'query_suffix' : '' ,
150154 }
151155 self .assertEqual (
152156 collector .prometheus .PrometheusCollector .check_configuration (data ),
@@ -158,13 +162,17 @@ def test_prometheus_minimal_config_minimal_extra_args(self):
158162 data ['metrics' ]['metric_one' ]['extra_args' ] = {
159163 'aggregation_method' : 'max' ,
160164 'query_function' : 'abs' ,
165+ 'query_prefix' : 'custom_prefix' ,
166+ 'query_suffix' : 'custom_suffix' ,
161167 'range_function' : 'delta' ,
162168 }
163169 expected_output = copy .deepcopy (self .base_output )
164170 expected_output ['metric_one' ]['groupby' ].append ('project_id' )
165171 expected_output ['metric_one' ]['extra_args' ] = {
166172 'aggregation_method' : 'max' ,
167173 'query_function' : 'abs' ,
174+ 'query_prefix' : 'custom_prefix' ,
175+ 'query_suffix' : 'custom_suffix' ,
168176 'range_function' : 'delta' ,
169177 }
170178
@@ -180,3 +188,26 @@ def test_check_duplicates(self):
180188 self .assertRaises (
181189 collector .InvalidConfiguration ,
182190 collector .check_duplicates , metric_name , metric )
191+
192+ def test_validate_map_mutator (self ):
193+ data = copy .deepcopy (self .base_data )
194+
195+ # Check that validation succeeds when MAP mutator is not used
196+ for metric_name , metric in data ['metrics' ].items ():
197+ collector .validate_map_mutator (metric_name , metric )
198+
199+ # Check that validation raises an exception when mutate_map is missing
200+ for metric_name , metric in data ['metrics' ].items ():
201+ metric ['mutate' ] = 'MAP'
202+ self .assertRaises (
203+ collector .InvalidConfiguration ,
204+ collector .validate_map_mutator , metric_name , metric )
205+
206+ data = copy .deepcopy (self .base_data )
207+ # Check that validation raises an exception when mutate_map is present
208+ # but MAP mutator is not used
209+ for metric_name , metric in data ['metrics' ].items ():
210+ metric ['mutate_map' ] = {}
211+ self .assertRaises (
212+ collector .InvalidConfiguration ,
213+ collector .validate_map_mutator , metric_name , metric )
0 commit comments