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
This commit is contained in:
parent
0fe02eb1c0
commit
fa9251a1ee
@ -772,22 +772,31 @@ class TestShell(testtools.TestCase):
|
|||||||
b'"Errors": [], "Number Deleted": 1, "Response Body": ""}')
|
b'"Errors": [], "Number Deleted": 1, "Response Body": ""}')
|
||||||
swiftclient.shell.main(argv)
|
swiftclient.shell.main(argv)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
connection.return_value.post_account.mock_calls, [
|
3, len(connection.return_value.post_account.mock_calls),
|
||||||
mock.call(query_string='bulk-delete',
|
'Expected 3 calls but found\n%r'
|
||||||
data=b'/container/object\n/container/obj%C3%A9ct2\n',
|
% connection.return_value.post_account.mock_calls)
|
||||||
headers={'Content-Type': 'text/plain',
|
# POSTs for same container are made in parallel so expect any order
|
||||||
'Accept': 'application/json'},
|
for expected in [
|
||||||
response_dict={}),
|
mock.call(query_string='bulk-delete',
|
||||||
mock.call(query_string='bulk-delete',
|
data=b'/container/object\n/container/obj%C3%A9ct2\n',
|
||||||
data=b'/container/object3\n',
|
headers={'Content-Type': 'text/plain',
|
||||||
headers={'Content-Type': 'text/plain',
|
'Accept': 'application/json'},
|
||||||
'Accept': 'application/json'},
|
response_dict={}),
|
||||||
response_dict={}),
|
mock.call(query_string='bulk-delete',
|
||||||
mock.call(query_string='bulk-delete',
|
data=b'/container/object3\n',
|
||||||
data=b'/container2/object\n',
|
headers={'Content-Type': 'text/plain',
|
||||||
headers={'Content-Type': 'text/plain',
|
'Accept': 'application/json'},
|
||||||
'Accept': 'application/json'},
|
response_dict={})]:
|
||||||
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(
|
self.assertEqual(
|
||||||
connection.return_value.delete_container.mock_calls, [
|
connection.return_value.delete_container.mock_calls, [
|
||||||
mock.call('container', response_dict={}),
|
mock.call('container', response_dict={}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user