From: PranaliDeore Date: Fri, 13 Mar 2015 06:47:12 +0000 (-0700) Subject: Mocked utils.execute for broken tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3566ab955ec137c39e252ac77d6f31dea3fa220e;p=openstack-build%2Fcinder-build.git Mocked utils.execute for broken tests Few tests were failing because utils.execute was not mocked. Added decorator @mock.patch('cinder.utils.execute') which will mock the utils.execute call for failing tests. Closes-Bug: #1430525 Change-Id: Ib54b83b1ad6dc42b084adf48ddd53a64a9b12cf7 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 18d5968a6..020bd1a1d 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -1189,8 +1189,11 @@ class VolumeTestCase(BaseVolumeTestCase): # cleanup resource db.volume_destroy(self.context, dst_vol_id) - def test_create_volume_from_volume_with_glance_volume_metadata_none(self): + @mock.patch('cinder.utils.execute') + def test_create_volume_from_volume_with_glance_volume_metadata_none( + self, mock_execute): # create source volume + mock_execute.return_value = None src_vol = tests_utils.create_volume(self.context, **self.volume_params) src_vol_id = src_vol['id'] @@ -1217,9 +1220,11 @@ class VolumeTestCase(BaseVolumeTestCase): db.volume_destroy(self.context, src_vol_id) db.volume_destroy(self.context, dst_vol['id']) + @mock.patch('cinder.utils.execute') def test_create_volume_from_volume_raise_metadata_copy_failure( - self): + self, mock_execute): # create source volume + mock_execute.return_value = None src_vol = tests_utils.create_volume(self.context, **self.volume_params) src_vol_id = src_vol['id'] @@ -1239,9 +1244,11 @@ class VolumeTestCase(BaseVolumeTestCase): # cleanup resource db.volume_destroy(self.context, src_vol_id) + @mock.patch('cinder.utils.execute') def test_create_volume_from_snapshot_raise_metadata_copy_failure( - self): + self, mock_execute): # create source volume + mock_execute.return_value = None src_vol = tests_utils.create_volume(self.context, **self.volume_params) src_vol_id = src_vol['id'] @@ -1271,8 +1278,10 @@ class VolumeTestCase(BaseVolumeTestCase): @mock.patch( 'cinder.volume.driver.VolumeDriver.create_replica_test_volume') + @mock.patch('cinder.utils.execute') def test_create_volume_from_srcreplica_raise_metadata_copy_failure( - self, _create_replica_test): + self, mock_execute, _create_replica_test): + mock_execute.return_value = None _create_replica_test.return_value = None # create source volume src_vol = tests_utils.create_volume(self.context, **self.volume_params) @@ -1294,9 +1303,11 @@ class VolumeTestCase(BaseVolumeTestCase): # cleanup resource db.volume_destroy(self.context, src_vol_id) + @mock.patch('cinder.utils.execute') def test_create_volume_from_snapshot_with_glance_volume_metadata_none( - self): + self, mock_execute): # create source volume + mock_execute.return_value = None src_vol = tests_utils.create_volume(self.context, **self.volume_params) src_vol_id = src_vol['id']