Add git review file

Add as well minor fixes just to pass gates

Change-Id: Ia5a52253bc23ec37541fcf07a4b1d00766e65054
This commit is contained in:
Boris Pavlovic 2014-06-09 20:01:03 +04:00
parent b2518bbe02
commit bcd678c7d9
5 changed files with 26 additions and 29 deletions

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=stackforge/osprofiler.git

View File

@ -54,9 +54,9 @@ def validate_hmac(content, expected_hmac, hmac_key):
class WsgiMiddleware(object):
"""WSGI Middleware that enables tracing for an application."""
def __init__(self, application, name='WSGI', enabled=False, hmac_key=None):
def __init__(self, application, enabled=False, hmac_key=None):
self.application = application
self.name = name
self.name = "wsgi"
self.enabled = enabled
self.hmac_key = hmac_key

View File

@ -1,22 +0,0 @@
# Copyright 2014 Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tests import test
class DummyTestCase(test.TestCase):
def test_dummy(self):
self.assertTrue(2 == 2)

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
import mock
from osprofiler import profiler
@ -125,7 +126,7 @@ class ProfilerTestCase(test.TestCase):
notifier.notify.assert_called_once_with(payload)
self.assertEqual(len(prof._name), 0)
self.assertEqual(prof._trace_stack, ["1", "2"])
self.assertEqual(prof._trace_stack, collections.deque(["1", "2"]))
def test_profiler_with_statement(self):
prof = profiler.Profiler(base_id="1", parent_id="2")

View File

@ -78,6 +78,12 @@ class WebMiddlewareTestCase(test.TestCase):
request = mock.MagicMock()
request.get_response.return_value = "yeah!"
request.url = "someurl"
request.host_url = "someurl"
request.path = "path"
request.query_string = "query"
request.method = "method"
request.scheme = "scheme"
trace_info = {"base_id": "1", "parent_id": "2"}
request.headers = {
"a": "1",
@ -91,9 +97,17 @@ class WebMiddlewareTestCase(test.TestCase):
with mock.patch("osprofiler.web.profiler.init") as mock_profiler_init:
mock_profiler_init.return_value = p
middleware = web.WsgiMiddleware("app", service_name="ss",
name="WSGI", enabled=True)
middleware = web.WsgiMiddleware("app", enabled=True)
self.assertEqual("yeah!", middleware(request))
mock_profiler_init.assert_called_once_with("1", "2", "ss")
p.start.assert_called_once_with("WSGI", info={"url": request.url})
mock_profiler_init.assert_called_once_with("1", "2", None)
expected_info = {
"request": {
"host_url": request.host_url,
"path": request.path,
"query": request.query_string,
"method": request.method,
"scheme": request.scheme
}
}
p.start.assert_called_once_with("wsgi", info=expected_info)
p.stop.assert_called_once_with()