From 4e0b199d177053d1ef547b9f8b57a4e69d189945 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 28 Nov 2017 15:58:15 -0600 Subject: [PATCH] Mock out CLI execution in NEC driver tests The VolumeStats_test was not mocking the CLI code that retieves backend stats, resulting in an ssh_known_hosts file being created in the local directory. This mocks out the calls to avoid this. Change-Id: I60898272e0da165fe3168e51d8595250682179c0 Closes-bug: #1732992 --- cinder/tests/unit/volume/drivers/nec/test_volume.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/nec/test_volume.py b/cinder/tests/unit/volume/drivers/nec/test_volume.py index 1bf13c54ca8..d7318be01ee 100644 --- a/cinder/tests/unit/volume/drivers/nec/test_volume.py +++ b/cinder/tests/unit/volume/drivers/nec/test_volume.py @@ -20,6 +20,7 @@ import mock from cinder import exception from cinder import test from cinder.volume import configuration as conf +from cinder.volume.drivers.nec import volume_common from cinder.volume.drivers.nec import volume_helper @@ -1095,8 +1096,6 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver, class VolumeStats_test(volume_helper.MStorageDSVDriver, test.TestCase): - @mock.patch('cinder.volume.drivers.nec.volume_common.MStorageVolumeCommon.' - '_create_ismview_dir', new=mock.Mock()) def setUp(self): super(VolumeStats_test, self).setUp() self._set_config(conf.Configuration(None), 'dummy', 'dummy') @@ -1106,6 +1105,8 @@ class VolumeStats_test(volume_helper.MStorageDSVDriver, test.TestCase): self._properties['pool_backup_pools'] = {2, 3} def test_update_volume_status(self): + self.mock_object(volume_common.MStorageVolumeCommon, 'parse_xml', + side_effect=Exception) stats = self._update_volume_status() self.assertEqual('dummy', stats.get('volume_backend_name')) self.assertEqual('NEC', stats.get('vendor_name'))