@@ -145,7 +145,7 @@ def test_get_scrape_pools(self): # noqa D102
145145 self .assertTrue (len (scrape_pools ) > 0 , "no scrape pools found" )
146146 self .assertIsInstance (scrape_pools [0 ], str )
147147
148- def test_get_targets (self ): # noqa D102
148+ def test_get_targets (self ): # PR #295
149149 targets = self .pc .get_targets ()
150150 self .assertIsInstance (targets , dict )
151151 self .assertIn ('activeTargets' , targets )
@@ -160,9 +160,8 @@ def test_get_targets(self): # noqa D102
160160 if len (scrape_pools := self .pc .get_scrape_pools ()) > 0 :
161161 pool_targets = self .pc .get_targets (scrape_pool = scrape_pools [0 ])
162162 self .assertIsInstance (pool_targets , dict )
163- self .assertIn ('activeTargets' , pool_targets )
164163
165- def test_get_target_metadata (self ): # noqa D102
164+ def test_get_target_metadata (self ): # PR #295
166165 # Get a target to test with
167166 targets = self .pc .get_targets ()
168167 if len (targets ['activeTargets' ]) > 0 :
@@ -171,42 +170,42 @@ def test_get_target_metadata(self): # noqa D102
171170 }
172171 metadata = self .pc .get_target_metadata (target )
173172 self .assertIsInstance (metadata , list )
174-
173+
175174 # Test with metric filter
176175 if len (metadata ) > 0 :
177176 metric_name = metadata [0 ]['metric' ]
178- filtered_metadata = self .pc .get_target_metadata (target , metric = metric_name )
177+ filtered_metadata = self .pc .get_target_metadata (
178+ target , metric = metric_name )
179179 self .assertIsInstance (filtered_metadata , list )
180- self .assertTrue (all (item ['metric' ] == metric_name for item in filtered_metadata ))
181-
182- # Test with limit
183- limited_metadata = self .pc .get_target_metadata (target , limit = 1 )
184- self .assertLessEqual (len (limited_metadata ), 1 )
180+ self .assertTrue (
181+ all (item ['target' ]['job' ] == target ['job' ] for item in filtered_metadata ))
182+
185183
186- def test_get_metric_metadata (self ): # noqa D102
184+ def test_get_metric_metadata (self ): # PR #295
187185 metadata = self .pc .get_metric_metadata (metric = None )
188186 self .assertIsInstance (metadata , list )
189187 self .assertTrue (len (metadata ) > 0 , "no metric metadata found" )
190-
188+
191189 # Check structure of metadata
192190 self .assertIn ('metric_name' , metadata [0 ])
193191 self .assertIn ('type' , metadata [0 ])
194192 self .assertIn ('help' , metadata [0 ])
195193 self .assertIn ('unit' , metadata [0 ])
196-
194+
197195 # Test with specific metric
198196 if len (metadata ) > 0 :
199197 metric_name = metadata [0 ]['metric_name' ]
200198 filtered_metadata = self .pc .get_metric_metadata (metric = metric_name )
201199 self .assertIsInstance (filtered_metadata , list )
202- self .assertTrue (all (item ['metric_name' ] == metric_name for item in filtered_metadata ))
203-
200+ self .assertTrue (
201+ all (item ['metric_name' ] == metric_name for item in filtered_metadata ))
202+
204203 # Test with limit
205- limited_metadata = self .pc .get_metric_metadata (limit = 1 )
204+ limited_metadata = self .pc .get_metric_metadata (metric_name , limit = 1 )
206205 self .assertLessEqual (len (limited_metadata ), 1 )
207-
206+
208207 # Test with limit_per_metric
209- limited_per_metric = self .pc .get_metric_metadata (limit_per_metric = 1 )
208+ limited_per_metric = self .pc .get_metric_metadata (metric_name , limit_per_metric = 1 )
210209 self .assertIsInstance (limited_per_metric , list )
211210
212211
0 commit comments