Merge "Convert http response(byte string) to string in python3."
This commit is contained in:
commit
e65e01014e
@ -931,7 +931,8 @@ def st_upload(parser, args, output_manager):
|
|||||||
if error.http_response_content:
|
if error.http_response_content:
|
||||||
if msg:
|
if msg:
|
||||||
msg += ': '
|
msg += ': '
|
||||||
msg += error.http_response_content[:60]
|
msg += (error.http_response_content
|
||||||
|
.decode('utf8')[:60])
|
||||||
msg = ': %s' % msg
|
msg = ': %s' % msg
|
||||||
else:
|
else:
|
||||||
msg = ': %s' % error
|
msg = ': %s' % error
|
||||||
|
@ -531,6 +531,27 @@ class TestShell(testtools.TestCase):
|
|||||||
'x-object-meta-mtime': mock.ANY},
|
'x-object-meta-mtime': mock.ANY},
|
||||||
response_dict={})
|
response_dict={})
|
||||||
|
|
||||||
|
@mock.patch('swiftclient.service.SwiftService.upload')
|
||||||
|
def test_upload_object_with_account_readonly(self, upload):
|
||||||
|
argv = ["", "upload", "container", self.tmpfile]
|
||||||
|
upload.return_value = [
|
||||||
|
{"success": False,
|
||||||
|
"headers": {},
|
||||||
|
"action": 'create_container',
|
||||||
|
"error": swiftclient.ClientException(
|
||||||
|
'Container PUT failed',
|
||||||
|
http_status=403,
|
||||||
|
http_reason='Forbidden',
|
||||||
|
http_response_content=b'<html><h1>Forbidden</h1>')
|
||||||
|
}]
|
||||||
|
|
||||||
|
with CaptureOutput() as output:
|
||||||
|
swiftclient.shell.main(argv)
|
||||||
|
self.assertTrue(output.err != '')
|
||||||
|
warning_msg = "Warning: failed to create container 'container': " \
|
||||||
|
"403 Forbidden"
|
||||||
|
self.assertTrue(output.err.startswith(warning_msg))
|
||||||
|
|
||||||
@mock.patch('swiftclient.service.Connection')
|
@mock.patch('swiftclient.service.Connection')
|
||||||
def test_upload_delete_slo_segments(self, connection):
|
def test_upload_delete_slo_segments(self, connection):
|
||||||
# Upload delete existing segments
|
# Upload delete existing segments
|
||||||
|
Loading…
x
Reference in New Issue
Block a user