Merge "Updated test_shell for Python3"
This commit is contained in:
@@ -18,9 +18,17 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
import swiftclient
|
import swiftclient
|
||||||
import swiftclient.shell
|
import swiftclient.shell
|
||||||
|
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
BUILTIN_OPEN = '__builtin__.open'
|
||||||
|
else:
|
||||||
|
BUILTIN_OPEN = 'builtins.open'
|
||||||
|
|
||||||
mocked_os_environ = {
|
mocked_os_environ = {
|
||||||
'ST_AUTH': 'http://localhost:8080/auth/v1.0',
|
'ST_AUTH': 'http://localhost:8080/auth/v1.0',
|
||||||
'ST_USER': 'test:tester',
|
'ST_USER': 'test:tester',
|
||||||
@@ -164,7 +172,7 @@ class TestShell(unittest.TestCase):
|
|||||||
mock.call(' 0')]
|
mock.call(' 0')]
|
||||||
mock_print.assert_has_calls(calls)
|
mock_print.assert_has_calls(calls)
|
||||||
|
|
||||||
@mock.patch('__builtin__.open')
|
@mock.patch(BUILTIN_OPEN)
|
||||||
@mock.patch('swiftclient.shell.Connection')
|
@mock.patch('swiftclient.shell.Connection')
|
||||||
def test_download(self, connection, mock_open):
|
def test_download(self, connection, mock_open):
|
||||||
connection.return_value.get_object.return_value = [
|
connection.return_value.get_object.return_value = [
|
||||||
@@ -217,7 +225,7 @@ class TestShell(unittest.TestCase):
|
|||||||
# Upload in segments
|
# Upload in segments
|
||||||
argv = ["", "upload", "container", self.tmpfile, "-S", "10"]
|
argv = ["", "upload", "container", self.tmpfile, "-S", "10"]
|
||||||
with open(self.tmpfile, "wb") as fh:
|
with open(self.tmpfile, "wb") as fh:
|
||||||
fh.write('12345678901234567890')
|
fh.write(b'12345678901234567890')
|
||||||
swiftclient.shell.main(argv)
|
swiftclient.shell.main(argv)
|
||||||
connection.return_value.put_object.assert_called_with(
|
connection.return_value.put_object.assert_called_with(
|
||||||
'container',
|
'container',
|
||||||
|
Reference in New Issue
Block a user