py3: fix test_proxy_logging.py
Only the tests needed to change, and it was nearly all just prepending "b" to a bunch of string literals. Change-Id: Id5317e471c04a05627438c281bb0d6a97cf6a8a4
This commit is contained in:
parent
2b19c26498
commit
e0b4eb225c
@ -17,6 +17,7 @@ import unittest
|
||||
from logging.handlers import SysLogHandler
|
||||
|
||||
import mock
|
||||
import six
|
||||
from six import BytesIO
|
||||
from six.moves.urllib.parse import unquote
|
||||
|
||||
@ -34,7 +35,9 @@ class FakeApp(object):
|
||||
|
||||
def __init__(self, body=None, response_str='200 OK', policy_idx='0'):
|
||||
if body is None:
|
||||
body = ['FAKE APP']
|
||||
body = [b'FAKE APP']
|
||||
elif isinstance(body, six.binary_type):
|
||||
body = [body]
|
||||
|
||||
self.body = body
|
||||
self.response_str = response_str
|
||||
@ -64,7 +67,7 @@ class FakeAppNoContentLengthNoTransferEncoding(object):
|
||||
|
||||
def __init__(self, body=None):
|
||||
if body is None:
|
||||
body = ['FAKE APP']
|
||||
body = [b'FAKE APP']
|
||||
|
||||
self.body = body
|
||||
|
||||
@ -93,7 +96,7 @@ class FakeAppReadline(object):
|
||||
start_response('200 OK', [('Content-Type', 'text/plain'),
|
||||
('Content-Length', '8')])
|
||||
env['wsgi.input'].readline()
|
||||
return ["FAKE APP"]
|
||||
return [b"FAKE APP"]
|
||||
|
||||
|
||||
def start_response(*args):
|
||||
@ -161,7 +164,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank(url, environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
# get body
|
||||
''.join(resp)
|
||||
b''.join(resp)
|
||||
self.assertEqual([], app.access_logger.log_dict['timing'])
|
||||
self.assertEqual([], app.access_logger.log_dict['update_stats'])
|
||||
|
||||
@ -203,7 +206,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
for path, exp_type in path_types.items():
|
||||
# GET
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeApp(body='7654321', response_str='321 Fubar'), {})
|
||||
FakeApp(body=b'7654321', response_str='321 Fubar'), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'GET',
|
||||
@ -211,7 +214,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
stub_times = [18.0, 20.71828182846]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
|
||||
self.assertEqual('7654321', ''.join(iter_response))
|
||||
self.assertEqual(b'7654321', b''.join(iter_response))
|
||||
self.assertTiming('%s.GET.321.timing' % exp_type, app,
|
||||
exp_timing=2.71828182846 * 1000)
|
||||
self.assertTimingSince(
|
||||
@ -236,7 +239,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
# Do this only for object types
|
||||
if exp_type == 'object':
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeApp(body='7654321', response_str='321 Fubar',
|
||||
FakeApp(body=b'7654321', response_str='321 Fubar',
|
||||
policy_idx='-1'), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
@ -245,7 +248,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
stub_times = [18.0, 20.71828182846]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
|
||||
self.assertEqual('7654321', ''.join(iter_response))
|
||||
self.assertEqual(b'7654321', b''.join(iter_response))
|
||||
self.assertTiming('%s.GET.321.timing' % exp_type, app,
|
||||
exp_timing=2.71828182846 * 1000)
|
||||
self.assertTimingSince(
|
||||
@ -258,7 +261,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
# GET with swift.proxy_access_log_made already set
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeApp(body='7654321', response_str='321 Fubar'), {})
|
||||
FakeApp(body=b'7654321', response_str='321 Fubar'), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'GET',
|
||||
@ -266,7 +269,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
'wsgi.input': BytesIO(b'4321')})
|
||||
stub_times = [18.0, 20.71828182846]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
self.assertEqual('7654321', ''.join(iter_response))
|
||||
self.assertEqual(b'7654321', b''.join(iter_response))
|
||||
self.assertEqual([], app.access_logger.log_dict['timing'])
|
||||
self.assertEqual([],
|
||||
app.access_logger.log_dict['timing_since'])
|
||||
@ -275,7 +278,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
# PUT (no first-byte timing!)
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeApp(body='87654321', response_str='314 PiTown'), {})
|
||||
FakeApp(body=b'87654321', response_str='314 PiTown'), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'PUT',
|
||||
@ -283,7 +286,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
# (it's not a GET, so time() doesn't have a 2nd call)
|
||||
stub_times = [58.2, 58.2 + 7.3321]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
self.assertEqual('87654321', ''.join(iter_response))
|
||||
self.assertEqual(b'87654321', b''.join(iter_response))
|
||||
self.assertTiming('%s.PUT.314.timing' % exp_type, app,
|
||||
exp_timing=7.3321 * 1000)
|
||||
self.assertNotTiming(
|
||||
@ -307,7 +310,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
# Do this only for object types
|
||||
if exp_type == 'object':
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeApp(body='87654321', response_str='314 PiTown',
|
||||
FakeApp(body=b'87654321', response_str='314 PiTown',
|
||||
policy_idx='-1'), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
@ -316,7 +319,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
# (it's not a GET, so time() doesn't have a 2nd call)
|
||||
stub_times = [58.2, 58.2 + 7.3321]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
self.assertEqual('87654321', ''.join(iter_response))
|
||||
self.assertEqual(b'87654321', b''.join(iter_response))
|
||||
self.assertTiming('%s.PUT.314.timing' % exp_type, app,
|
||||
exp_timing=7.3321 * 1000)
|
||||
self.assertNotTiming(
|
||||
@ -384,13 +387,13 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_basic_req_second_time(self):
|
||||
@ -400,24 +403,24 @@ class TestProxyLogging(unittest.TestCase):
|
||||
'swift.proxy_access_log_made': True,
|
||||
'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
self._log_parts(app, should_be_empty=True)
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
|
||||
def test_multi_segment_resp(self):
|
||||
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(
|
||||
['some', 'chunks', 'of data']), {})
|
||||
[b'some', b'chunks', b'of data']), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'swift.source': 'SOS'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'somechunksof data')
|
||||
self.assertEqual(resp_body, b'somechunksof data')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
self.assertUpdateStats([('SOS.GET.200.xfer', len(resp_body))], app)
|
||||
|
||||
@ -634,7 +637,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
try:
|
||||
resp = app(req.environ, start_response)
|
||||
# read body
|
||||
''.join(resp)
|
||||
b''.join(resp)
|
||||
except IOError:
|
||||
pass
|
||||
log_parts = self._log_parts(app)
|
||||
@ -650,7 +653,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
try:
|
||||
resp = app(req.environ, start_response)
|
||||
# read body
|
||||
''.join(resp)
|
||||
b''.join(resp)
|
||||
except IOError:
|
||||
pass
|
||||
log_parts = self._log_parts(app)
|
||||
@ -674,18 +677,18 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeAppNoContentLengthNoTransferEncoding(
|
||||
# test the "while not chunk: chunk = next(iterator)"
|
||||
body=['', '', 'line1\n', 'line2\n'],
|
||||
body=[b'', b'', b'line1\n', b'line2\n'],
|
||||
), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'line1\nline2\n')
|
||||
self.assertEqual(resp_body, b'line1\nline2\n')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_no_content_length_no_transfer_encoding_with_empty_strings(self):
|
||||
@ -697,13 +700,13 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, '')
|
||||
self.assertEqual(resp_body, b'')
|
||||
self.assertEqual(log_parts[11], '-')
|
||||
|
||||
def test_no_content_length_no_transfer_encoding_with_generator(self):
|
||||
@ -717,18 +720,18 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
app = proxy_logging.ProxyLoggingMiddleware(
|
||||
FakeAppNoContentLengthNoTransferEncoding(
|
||||
body=BodyGen('abc'),
|
||||
body=BodyGen(b'abc'),
|
||||
), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'abc')
|
||||
self.assertEqual(resp_body, b'abc')
|
||||
self.assertEqual(log_parts[11], '3')
|
||||
|
||||
def test_req_path_info_popping(self):
|
||||
@ -738,13 +741,13 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req.path_info_pop()
|
||||
self.assertEqual(req.environ['PATH_INFO'], '/something')
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/v1/something')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_ipv6(self):
|
||||
@ -754,7 +757,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
req.remote_addr = ipv6addr
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[0], ipv6addr)
|
||||
self.assertEqual(log_parts[1], ipv6addr)
|
||||
@ -762,7 +765,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_log_info_none(self):
|
||||
@ -808,7 +811,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], '-')
|
||||
# Has x-auth-token header
|
||||
@ -817,7 +820,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'HTTP_X_AUTH_TOKEN': auth_token})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], 'b05bf940-0464-4c...')
|
||||
|
||||
@ -827,7 +830,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], '-')
|
||||
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
|
||||
@ -836,7 +839,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'HTTP_X_AUTH_TOKEN': auth_token})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], 'b05bf940...')
|
||||
|
||||
@ -847,7 +850,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'HTTP_X_AUTH_TOKEN': auth_token})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], auth_token)
|
||||
|
||||
@ -858,7 +861,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'HTTP_X_AUTH_TOKEN': auth_token})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], auth_token)
|
||||
|
||||
@ -868,7 +871,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], '-')
|
||||
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
|
||||
@ -877,7 +880,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||
'HTTP_X_AUTH_TOKEN': auth_token})
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[9], '...')
|
||||
|
||||
@ -893,7 +896,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
mock.MagicMock(
|
||||
side_effect=[10000000.0, 10000001.0])):
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(len(log_parts), 21)
|
||||
self.assertEqual(log_parts[0], '-')
|
||||
@ -907,7 +910,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertEqual(log_parts[8], '-')
|
||||
self.assertEqual(log_parts[9], '-')
|
||||
self.assertEqual(log_parts[10], '-')
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
self.assertEqual(log_parts[12], '-')
|
||||
self.assertEqual(log_parts[13], '-')
|
||||
@ -931,14 +934,14 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = log1(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
self._log_parts(log0, should_be_empty=True)
|
||||
log_parts = self._log_parts(log1)
|
||||
self.assertEqual(log_parts[3], 'GET')
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'FAKE APP')
|
||||
self.assertEqual(resp_body, b'FAKE APP')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_dual_logging_middlewares_w_inner(self):
|
||||
@ -956,13 +959,13 @@ class TestProxyLogging(unittest.TestCase):
|
||||
# Make the internal request
|
||||
ireq = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = self.app(ireq.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
if resp_body != 'FAKE APP':
|
||||
resp_body = b''.join(resp)
|
||||
if resp_body != b'FAKE APP':
|
||||
return Response(request=req,
|
||||
body="FAKE APP WAS NOT RETURNED",
|
||||
body=b"FAKE APP WAS NOT RETURNED",
|
||||
content_type="text/plain")
|
||||
# But our response is different
|
||||
return Response(request=req, body="FAKE MIDDLEWARE",
|
||||
return Response(request=req, body=b"FAKE MIDDLEWARE",
|
||||
content_type="text/plain")
|
||||
|
||||
def __call__(self, env, start_response):
|
||||
@ -981,7 +984,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = log1(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
resp_body = b''.join(resp)
|
||||
|
||||
# Inner most logger should have logged the app's response
|
||||
log_parts = self._log_parts(log0)
|
||||
@ -997,7 +1000,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
self.assertEqual(log_parts[4], '/')
|
||||
self.assertEqual(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEqual(log_parts[6], '200')
|
||||
self.assertEqual(resp_body, 'FAKE MIDDLEWARE')
|
||||
self.assertEqual(resp_body, b'FAKE MIDDLEWARE')
|
||||
self.assertEqual(log_parts[11], str(len(resp_body)))
|
||||
|
||||
def test_policy_index(self):
|
||||
@ -1007,7 +1010,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'})
|
||||
resp = app(req.environ, start_response)
|
||||
''.join(resp)
|
||||
b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[20], '1')
|
||||
|
||||
@ -1028,6 +1031,6 @@ class TestProxyLogging(unittest.TestCase):
|
||||
|
||||
with mock.patch.object(FakeApp, '__call__', fake_call):
|
||||
resp = app(req.environ, start_response)
|
||||
''.join(resp)
|
||||
b''.join(resp)
|
||||
log_parts = self._log_parts(app)
|
||||
self.assertEqual(log_parts[20], '1')
|
||||
|
1
tox.ini
1
tox.ini
@ -37,6 +37,7 @@ commands =
|
||||
test/unit/cli/test_ring_builder_analyzer.py \
|
||||
test/unit/cli/test_ringbuilder.py \
|
||||
test/unit/common/middleware/test_gatekeeper.py \
|
||||
test/unit/common/middleware/test_proxy_logging.py \
|
||||
test/unit/common/ring \
|
||||
test/unit/common/test_constraints.py \
|
||||
test/unit/common/test_daemon.py \
|
||||
|
Loading…
Reference in New Issue
Block a user