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

Method test_qs_parsing

tests/test_asgi.py:194–225  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

192 assert content_type == "text/plain"
193
194 def test_qs_parsing(self):
195 """Only metrics that match the 'name[]' query string param appear"""
196
197 app = make_asgi_app(self.registry)
198 metrics = [
199 ("asdf", "first test metric", 1),
200 ("bsdf", "second test metric", 2)
201 ]
202
203 for m in metrics:
204 self.increment_metrics(*m)
205
206 for i_1 in range(len(metrics)):
207 self.seed_app(app)
208 self.scope['query_string'] = f"name[]={metrics[i_1][0]}_total".encode("utf-8")
209 self.send_default_request()
210
211 outputs = self.get_all_output()
212 response_body = outputs[1]
213 output = response_body['body'].decode('utf8')
214
215 self.assert_metrics(output, *metrics[i_1])
216
217 for i_2 in range(len(metrics)):
218 if i_1 == i_2:
219 continue
220
221 self.assert_not_metrics(output, *metrics[i_2])
222
223 asyncio.new_event_loop().run_until_complete(
224 self.communicator.wait()
225 )
226
227 def test_qs_parsing_multi(self):
228 """Only metrics that match the 'name[]' query string param appear"""

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected