Mock auth_end_time in test_shell.test_download
If we don't we are getting an error like this under py3: TypeError: unsupported operand type(s) for /: 'float' and 'MagicMock' Change-Id: If5a6947757297354e6b81fc45f011cc2921d609f
This commit is contained in:
parent
a99c2ff581
commit
0fc27f6c28
@ -172,9 +172,8 @@ 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('swiftclient.shell.Connection')
|
@mock.patch('swiftclient.shell.Connection')
|
||||||
def test_download(self, connection, mock_open):
|
def test_download(self, connection):
|
||||||
connection.return_value.get_object.return_value = [
|
connection.return_value.get_object.return_value = [
|
||||||
{'content-type': 'text/plain',
|
{'content-type': 'text/plain',
|
||||||
'etag': 'd41d8cd98f00b204e9800998ecf8427e'},
|
'etag': 'd41d8cd98f00b204e9800998ecf8427e'},
|
||||||
@ -185,18 +184,23 @@ class TestShell(unittest.TestCase):
|
|||||||
[None, [{'name': 'object'}]],
|
[None, [{'name': 'object'}]],
|
||||||
[None, []],
|
[None, []],
|
||||||
]
|
]
|
||||||
|
connection.return_value.auth_end_time = 0
|
||||||
connection.return_value.attempts = 0
|
connection.return_value.attempts = 0
|
||||||
|
|
||||||
argv = ["", "download", "container"]
|
with mock.patch(BUILTIN_OPEN) as mock_open:
|
||||||
swiftclient.shell.main(argv)
|
argv = ["", "download", "container"]
|
||||||
connection.return_value.get_object.assert_called_with(
|
swiftclient.shell.main(argv)
|
||||||
'container', 'object', headers={}, resp_chunk_size=65536)
|
connection.return_value.get_object.assert_called_with(
|
||||||
|
'container', 'object', headers={}, resp_chunk_size=65536)
|
||||||
|
mock_open.assert_called_with('object', 'wb')
|
||||||
|
|
||||||
# Test downloading single object
|
# Test downloading single object
|
||||||
argv = ["", "download", "container", "object"]
|
with mock.patch(BUILTIN_OPEN) as mock_open:
|
||||||
swiftclient.shell.main(argv)
|
argv = ["", "download", "container", "object"]
|
||||||
connection.return_value.get_object.assert_called_with(
|
swiftclient.shell.main(argv)
|
||||||
'container', 'object', headers={}, resp_chunk_size=65536)
|
connection.return_value.get_object.assert_called_with(
|
||||||
|
'container', 'object', headers={}, resp_chunk_size=65536)
|
||||||
|
mock_open.assert_called_with('object', 'wb')
|
||||||
|
|
||||||
@mock.patch('swiftclient.shell.listdir')
|
@mock.patch('swiftclient.shell.listdir')
|
||||||
@mock.patch('swiftclient.shell.Connection')
|
@mock.patch('swiftclient.shell.Connection')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user