MCPcopy Index your code
hub / github.com/prometheus/client_python / test_qs_parsing_multi

Method test_qs_parsing_multi

tests/test_asgi.py:227–254  ·  view source on GitHub ↗

Only metrics that match the 'name[]' query string param appear

(self)

Source from the content-addressed store, hash-verified

225 )
226
227 def test_qs_parsing_multi(self):
228 """Only metrics that match the 'name[]' query string param appear"""
229
230 app = make_asgi_app(self.registry)
231 metrics = [
232 ("asdf", "first test metric", 1),
233 ("bsdf", "second test metric", 2),
234 ("csdf", "third test metric", 3)
235 ]
236
237 for m in metrics:
238 self.increment_metrics(*m)
239
240 self.seed_app(app)
241 self.scope['query_string'] = "&".join([f"name[]={m[0]}_total" for m in metrics[0:2]]).encode("utf-8")
242 self.send_default_request()
243
244 outputs = self.get_all_output()
245 response_body = outputs[1]
246 output = response_body['body'].decode('utf8')
247
248 self.assert_metrics(output, *metrics[0])
249 self.assert_metrics(output, *metrics[1])
250 self.assert_not_metrics(output, *metrics[2])
251
252 asyncio.new_event_loop().run_until_complete(
253 self.communicator.wait()
254 )

Callers

nothing calls this directly

Calls 8

increment_metricsMethod · 0.95
seed_appMethod · 0.95
send_default_requestMethod · 0.95
get_all_outputMethod · 0.95
assert_metricsMethod · 0.95
assert_not_metricsMethod · 0.95
make_asgi_appFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected