summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-04-14 02:02:34 +0000
committerGerrit Code Review <review@openstack.org>2016-04-14 02:02:34 +0000
commitab636c1ee34a223c91b5d5b32e90468539d8b253 (patch)
treec8bd27b680fb0608e0a0c61d928ffbd48c671c06
parent015903e383a27318918ee7827574ecb120110ae2 (diff)
parent909bdf89542a9d021eb2ddcb951950f36245bc8b (diff)
downloadpython-swiftclient-ab636c1ee34a223c91b5d5b32e90468539d8b253.tar.gz
Merge "Fix downloading from "marker" item"
-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 53d7d99..06c37b3 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()