diff options
author | Tim Burke <tim.burke@gmail.com> | 2015-06-11 14:33:39 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2016-01-12 15:40:57 -0800 |
commit | 7a1e192803b8f4b739c9c3086bbfdc9a9c8d6753 (patch) | |
tree | 508af2dd3f12e97927508ec032640b9c33e9baa2 /tests/unit/test_utils.py | |
parent | 6ed6c3343f73e170b259c1dc1956017da2c17620 (diff) | |
download | python-swiftclient-7a1e192803b8f4b739c9c3086bbfdc9a9c8d6753.tar.gz |
Use bulk-delete middleware when available
When issuing `delete` commands that would require three or more
individual deletes, check whether the cluster supports bulk deletes
and use that if it's available.
Additionally, a new option is added to the `delete` command:
* --prefix <prefix>
Delete all objects that start with <prefix>. This is similar to the
--prefix option for the `list` command.
Example:
$ swift delete c --prefix obj_prefix/
...will delete from container "c" all objects whose name begins with
"obj_prefix/", such as "obj_prefix/foo" and "obj_prefix/bar".
Change-Id: I6b9504848d6ef562cf4f570bbcd17db4e3da8264
Diffstat (limited to 'tests/unit/test_utils.py')
-rw-r--r-- | tests/unit/test_utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 3439f4a..fe50f55 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -290,3 +290,31 @@ class TestLengthWrapper(testtools.TestCase): self.assertEqual(segment_length, len(read_data)) self.assertEqual(s, read_data) self.assertEqual(md5(s).hexdigest(), data.get_md5sum()) + + +class TestGroupers(testtools.TestCase): + def test_n_at_a_time(self): + result = list(u.n_at_a_time(range(100), 9)) + self.assertEqual([9] * 11 + [1], list(map(len, result))) + + result = list(u.n_at_a_time(range(100), 10)) + self.assertEqual([10] * 10, list(map(len, result))) + + result = list(u.n_at_a_time(range(100), 11)) + self.assertEqual([11] * 9 + [1], list(map(len, result))) + + result = list(u.n_at_a_time(range(100), 12)) + self.assertEqual([12] * 8 + [4], list(map(len, result))) + + def test_n_groups(self): + result = list(u.n_groups(range(100), 9)) + self.assertEqual([12] * 8 + [4], list(map(len, result))) + + result = list(u.n_groups(range(100), 10)) + self.assertEqual([10] * 10, list(map(len, result))) + + result = list(u.n_groups(range(100), 11)) + self.assertEqual([10] * 10, list(map(len, result))) + + result = list(u.n_groups(range(100), 12)) + self.assertEqual([9] * 11 + [1], list(map(len, result))) |