summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hpe.com>2016-02-01 10:07:55 +0000
committerAlistair Coles <alistair.coles@hpe.com>2016-02-01 10:07:55 +0000
commitfa9251a1ee9bfc27664d88c5fe6bbb23e8fa1e51 (patch)
tree169fd721069510b6db70570e356835217a872983 /tests/unit/test_shell.py
parent0fe02eb1c006d7d70f638f8012aa370fdf4b6096 (diff)
downloadpython-swiftclient-fa9251a1ee9bfc27664d88c5fe6bbb23e8fa1e51.tar.gz
Fix intermittent fail of test_delete_bulk_account
The test asserts calls made in specific order, but they are made from threads so may be in different order. Change-Id: I857ad3b909c3b635927fb1a39682d66d20c6fd59
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r--tests/unit/test_shell.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index 01288c1..5313d41 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -772,22 +772,31 @@ class TestShell(testtools.TestCase):
b'"Errors": [], "Number Deleted": 1, "Response Body": ""}')
swiftclient.shell.main(argv)
self.assertEqual(
- connection.return_value.post_account.mock_calls, [
- mock.call(query_string='bulk-delete',
- data=b'/container/object\n/container/obj%C3%A9ct2\n',
- headers={'Content-Type': 'text/plain',
- 'Accept': 'application/json'},
- response_dict={}),
- mock.call(query_string='bulk-delete',
- data=b'/container/object3\n',
- headers={'Content-Type': 'text/plain',
- 'Accept': 'application/json'},
- response_dict={}),
- mock.call(query_string='bulk-delete',
- data=b'/container2/object\n',
- headers={'Content-Type': 'text/plain',
- 'Accept': 'application/json'},
- response_dict={})])
+ 3, len(connection.return_value.post_account.mock_calls),
+ 'Expected 3 calls but found\n%r'
+ % connection.return_value.post_account.mock_calls)
+ # POSTs for same container are made in parallel so expect any order
+ for expected in [
+ mock.call(query_string='bulk-delete',
+ data=b'/container/object\n/container/obj%C3%A9ct2\n',
+ headers={'Content-Type': 'text/plain',
+ 'Accept': 'application/json'},
+ response_dict={}),
+ mock.call(query_string='bulk-delete',
+ data=b'/container/object3\n',
+ headers={'Content-Type': 'text/plain',
+ 'Accept': 'application/json'},
+ response_dict={})]:
+ self.assertIn(expected,
+ connection.return_value.post_account.mock_calls[:2])
+ # POSTs for different containers are made sequentially so expect order
+ self.assertEqual(
+ mock.call(query_string='bulk-delete',
+ data=b'/container2/object\n',
+ headers={'Content-Type': 'text/plain',
+ 'Accept': 'application/json'},
+ response_dict={}),
+ connection.return_value.post_account.mock_calls[2])
self.assertEqual(
connection.return_value.delete_container.mock_calls, [
mock.call('container', response_dict={}),