@@ -145,7 +145,7 @@ def test_get_scrape_pools(self): # noqa D102
145
145
self .assertTrue (len (scrape_pools ) > 0 , "no scrape pools found" )
146
146
self .assertIsInstance (scrape_pools [0 ], str )
147
147
148
- def test_get_targets (self ): # noqa D102
148
+ def test_get_targets (self ): # PR #295
149
149
targets = self .pc .get_targets ()
150
150
self .assertIsInstance (targets , dict )
151
151
self .assertIn ('activeTargets' , targets )
@@ -160,9 +160,8 @@ def test_get_targets(self): # noqa D102
160
160
if len (scrape_pools := self .pc .get_scrape_pools ()) > 0 :
161
161
pool_targets = self .pc .get_targets (scrape_pool = scrape_pools [0 ])
162
162
self .assertIsInstance (pool_targets , dict )
163
- self .assertIn ('activeTargets' , pool_targets )
164
163
165
- def test_get_target_metadata (self ): # noqa D102
164
+ def test_get_target_metadata (self ): # PR #295
166
165
# Get a target to test with
167
166
targets = self .pc .get_targets ()
168
167
if len (targets ['activeTargets' ]) > 0 :
@@ -171,42 +170,42 @@ def test_get_target_metadata(self): # noqa D102
171
170
}
172
171
metadata = self .pc .get_target_metadata (target )
173
172
self .assertIsInstance (metadata , list )
174
-
173
+
175
174
# Test with metric filter
176
175
if len (metadata ) > 0 :
177
176
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 )
179
179
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
+
185
183
186
- def test_get_metric_metadata (self ): # noqa D102
184
+ def test_get_metric_metadata (self ): # PR #295
187
185
metadata = self .pc .get_metric_metadata (metric = None )
188
186
self .assertIsInstance (metadata , list )
189
187
self .assertTrue (len (metadata ) > 0 , "no metric metadata found" )
190
-
188
+
191
189
# Check structure of metadata
192
190
self .assertIn ('metric_name' , metadata [0 ])
193
191
self .assertIn ('type' , metadata [0 ])
194
192
self .assertIn ('help' , metadata [0 ])
195
193
self .assertIn ('unit' , metadata [0 ])
196
-
194
+
197
195
# Test with specific metric
198
196
if len (metadata ) > 0 :
199
197
metric_name = metadata [0 ]['metric_name' ]
200
198
filtered_metadata = self .pc .get_metric_metadata (metric = metric_name )
201
199
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
+
204
203
# 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 )
206
205
self .assertLessEqual (len (limited_metadata ), 1 )
207
-
206
+
208
207
# 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 )
210
209
self .assertIsInstance (limited_per_metric , list )
211
210
212
211
0 commit comments