summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Gotliv <sgotliv@redhat.com>2016-04-03 07:37:33 +0300
committerPete Zaitcev <zaitcev@kotori.zaitcev.us>2016-04-08 20:55:18 -0600
commit909bdf89542a9d021eb2ddcb951950f36245bc8b (patch)
tree0669f22fe1804a20e4db4b4d4198df0c9a465de4
parentf86b2d8138f5c366d0f8ab8e8cb2492d9cd07ca4 (diff)
downloadpython-swiftclient-909bdf89542a9d021eb2ddcb951950f36245bc8b.tar.gz
Fix downloading from "marker" item
The documentation of "swift download" hints that "marker" option is supported, but in reality we forgot to patch it through, so all downloads were always done with the default, empty marker. Closes-Bug: #1565393 Change-Id: I38bd29d2baa9188b61397dec75ce1d864041653c
-rw-r--r--swiftclient/service.py2
-rwxr-xr-xswiftclient/shell.py4
-rw-r--r--tests/unit/test_service.py35
3 files changed, 38 insertions, 3 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py
index 99c833e..7d6f6be 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -883,7 +883,7 @@ class SwiftService(object):
@staticmethod
def _list_container_job(conn, container, options, result_queue):
- marker = ''
+ marker = options.get('marker', '')
error = None
try:
while True:
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 2c5bca8..c1b893d 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -203,7 +203,7 @@ def st_delete(parser, args, output_manager):
output_manager.error(err.value)
-st_download_options = '''[--all] [--marker] [--prefix <prefix>]
+st_download_options = '''[--all] [--marker <marker>] [--prefix <prefix>]
[--output <out_file>] [--output-dir <out_directory>]
[--object-threads <threads>]
[--container-threads <threads>] [--no-download]
@@ -225,7 +225,7 @@ Positional arguments:
Optional arguments:
-a, --all Indicates that you really want to download
everything in the account.
- -m, --marker Marker to use when starting a container or account
+ -m, --marker <marker> Marker to use when starting a container or account
download.
-p, --prefix <prefix> Only download items beginning with <prefix>
-r, --remove-prefix An optional flag for --prefix <prefix>, use this
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py
index e9310aa..3094780 100644
--- a/tests/unit/test_service.py
+++ b/tests/unit/test_service.py
@@ -687,6 +687,41 @@ class TestServiceList(_TestServiceBase):
self.assertEqual(expected_r_long, self._get_queue(mock_q))
self.assertIsNone(self._get_queue(mock_q))
+ def test_list_container_marker(self):
+ mock_q = Queue()
+ mock_conn = self._get_mock_connection()
+
+ get_container_returns = [
+ (None, [{'name': 'b'}, {'name': 'c'}]),
+ (None, [])
+ ]
+ mock_get_cont = Mock(side_effect=get_container_returns)
+ mock_conn.get_container = mock_get_cont
+
+ expected_r = self._get_expected({
+ 'action': 'list_container_part',
+ 'container': 'test_c',
+ 'success': True,
+ 'listing': [{'name': 'b'}, {'name': 'c'}],
+ 'marker': 'b'
+ })
+
+ _opts = self.opts.copy()
+ _opts['marker'] = 'b'
+ SwiftService._list_container_job(mock_conn, 'test_c', _opts, mock_q)
+
+ # This does not test if the marker is propagated, because we always
+ # get the final call to the get_container with the final item 'c',
+ # even if marker wasn't set. This test just makes sure the whole
+ # stack works in a sane way.
+ mock_kw = mock_get_cont.call_args[1]
+ self.assertEqual(mock_kw['marker'], 'c')
+
+ # This tests that the lower levels get the marker delivered.
+ self.assertEqual(expected_r, self._get_queue(mock_q))
+
+ self.assertIsNone(self._get_queue(mock_q))
+
def test_list_container_exception(self):
mock_q = Queue()
mock_conn = self._get_mock_connection()