Files
connexion/tests/test_metrics.py
Daniel Grossmann-Kavanagh 08e4536e5e bump and pin isort, apply all automatic fixes (#903)
Fixes the build.

Changes proposed in this pull request:
 - apply all of the isort changes that resulted from the latest version
 - pin to the latest version (4.3.15) so this doesn't happen again, unless we bump the version on purpose
2019-03-15 13:04:33 +01:00

24 lines
735 B
Python

import json
import flask
from mock import MagicMock
import connexion
from connexion.decorators.metrics import UWSGIMetricsCollector
def test_timer(monkeypatch):
wrapper = UWSGIMetricsCollector('/foo/bar/<param>', 'get')
def operation(req):
return connexion.problem(418, '', '')
op = wrapper(operation)
metrics = MagicMock()
monkeypatch.setattr('flask.request', MagicMock())
monkeypatch.setattr('flask.current_app', MagicMock(response_class=flask.Response))
monkeypatch.setattr('connexion.decorators.metrics.uwsgi_metrics', metrics)
op(MagicMock())
assert metrics.timer.call_args[0][:2] == ('connexion.response',
'418.GET.foo.bar.{param}')