Fix tests failing in gate

gate-cinder-python27 gate-cinder-python34 is reporting failures where it
wasn't before. This is all due to new mock version 1.1.0.  This patch
fixed the tests to pass the gate.

Some of these errors are actual errors in our test code, while other are
changes to Mock syntax.

Closes-Bug: #1473454
Change-Id: If8eabfeacacc221e92dfece9f4937875bd70751e
This commit is contained in:
Gorka Eguileor 2015-07-10 13:20:16 +02:00
parent 5669075b28
commit 0f588ac59b
4 changed files with 10 additions and 10 deletions

View File

@ -106,7 +106,7 @@ def _patch_mock_to_raise_for_invalid_assert_calls():
'assert_called_with',
'assert_called_once_with',
'assert_has_calls',
'assert_any_calls']
'assert_any_call']
if name.startswith('assert') and name not in valid_asserts:
raise AttributeError('%s is not a valid mock assert method'

View File

@ -157,11 +157,11 @@ class TestIetAdmDriver(tf.TargetDriverFixture):
0,
self.testvol['id'],
self.testvol['name'])
mock_execute.assert_any_calls('ietadm',
'--op',
'delete',
'--tid=1',
run_as_root=True)
mock_execute.assert_any_call('ietadm',
'--op',
'delete',
'--tid=1',
run_as_root=True)
# Test the failure case: putils.ProcessExecutionError
mock_execute.side_effect = putils.ProcessExecutionError

View File

@ -205,8 +205,8 @@ class PureDriverTestCase(test.TestCase):
"""
func(*args, **kwargs)
for mock_func in mocks:
mock_func.side_effect = exception.PureDriverException(
reason="reason")
mock_func.side_effect = [exception.PureDriverException(
reason='reason')]
self.assertRaises(exception.PureDriverException,
func, *args, **kwargs)
mock_func.side_effect = None

View File

@ -55,12 +55,12 @@ class MockAssertTestCase(test.TestCase):
mock_call(2)
mock_call.assert_has_calls([mock.call(1), mock.call(2)])
def test_assert_any_calls(self):
def test_assert_any_call(self):
mock_call = mock.MagicMock(return_value=None)
mock_call(1)
mock_call(2)
mock_call(3)
mock_call.assert_any_calls([mock.call(1)])
mock_call.assert_any_call(1)
def test_assert_called_with(self):
mock_call = mock.MagicMock(return_value=None)