]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix tests failing in gate
authorGorka Eguileor <geguileo@redhat.com>
Fri, 10 Jul 2015 11:20:16 +0000 (13:20 +0200)
committerGorka Eguileor <geguileo@redhat.com>
Fri, 10 Jul 2015 14:15:32 +0000 (16:15 +0200)
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

cinder/test.py
cinder/tests/unit/targets/test_iet_driver.py
cinder/tests/unit/test_pure.py
cinder/tests/unit/test_test.py

index ce101d3f58499ce07f8dbd528690a543bffe54ac..c8433d1262a661ceeb9be40f578b100ba1283a65 100644 (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'
index 9f6921bbea2d86113ff4077b1e60157347eabbc2..92e8a4ea3776ea65788dee0516fb199bc733bf3a 100644 (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
index 075faafaa3d23082c9a0882665cd076de425ec99..98594eecc2d2dd0010fb573f5fa939473acde607 100644 (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
index 1078c8e735df8113c9b60e12c857f2eb46d45739..fb15b09d719ec3225509d91cc11b614c6ffccef0 100644 (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)