From 997ed18ee1e69f619818eb92144a2dc0e706e618 Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Mon, 25 Aug 2014 13:09:14 -0500 Subject: [PATCH] Mock processutils.execute properly in test_ibmnas test_delete_snapfiles and test_delete_snapfiles_nas_gpfs were not properly mocking out cinder.openstack.common.processutils.execute . This was causing the unittests to prompt for a sudo password during unit test on some systems. This change mocks out processutils.execute to return what is expected for this test case. Change-Id: I67f26cfd3157813758de7785157a21ebe5230833 Closes-bug: 1361287 --- cinder/tests/test_ibmnas.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/cinder/tests/test_ibmnas.py b/cinder/tests/test_ibmnas.py index a446cea43..77bbcfc96 100644 --- a/cinder/tests/test_ibmnas.py +++ b/cinder/tests/test_ibmnas.py @@ -300,30 +300,36 @@ class IBMNASDriverTestCase(test.TestCase): self.TEST_EXTEND_SIZE_IN_GB) @mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver._run_ssh') - def test_delete_snapfiles(self, mock_ssh): + @mock.patch('cinder.openstack.common.processutils.execute') + def test_delete_snapfiles(self, mock_ssh, mock_execute): """Delete_snapfiles test case.""" drv = self._driver - mock_ssh.return_value = ('Parent Depth Parent inode' - 'File name\n yes 0 /ibm/gpfs0/gshare/\n' - 'volume-123\n EFSSG1000I The command' - 'completed successfully.', '') + expected = ('Parent Depth Parent inode' + 'File name\n yes 0 /ibm/gpfs0/gshare/\n' + 'volume-123\n EFSSG1000I The command' + 'completed successfully.', '') + mock_execute.return_value = expected + mock_ssh.return_value = expected drv._delete_snapfiles(self.TEST_VOLUME_PATH, self.TEST_MNT_POINT) @mock.patch('cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver._run_ssh') - def test_delete_snapfiles_nas_gpfs(self, mock_ssh): + @mock.patch('cinder.openstack.common.processutils.execute') + def test_delete_snapfiles_nas_gpfs(self, mock_ssh, mock_execute): """Delete_snapfiles for gpfs-nas platform test case.""" drv = self._driver drv.configuration.platform = 'gpfs-nas' - mock_ssh.return_value = ('Parent Depth Parent inode' - 'File name\n' - '------ ----- -------------' - '- ---------\n' - 'yes 0\n' - '/ibm/gpfs0/gshare/volume-123', '') + expected = ('Parent Depth Parent inode' + 'File name\n' + '------ ----- -------------' + '- ---------\n' + 'yes 0\n' + '/ibm/gpfs0/gshare/volume-123', '') + mock_execute.return_value = expected + mock_ssh.return_value = expected drv._delete_snapfiles(self.TEST_VOLUME_PATH, self.TEST_MNT_POINT) -- 2.45.2