'do_setup should throw error if mount.nfs fails with OSError
This test covers the OSError path when mount.nfs is installed.'

def test_setup_should_throw_exception_if_mount_nfs_command_fails(self):

    drv = nfs.NfsDriver(configuration=self.configuration)
    mock_os_path_exists = self.mock_object(os.path, 'exists')
    mock_os_path_exists.return_value = True
    mock_execute = self.mock_object(drv, '_execute')
    mock_execute.side_effect = OSError(errno.EPERM, 'Operation...    BROKEN')
    with self.assertRaisesRegex(OSError, '.*Operation...    BROKEN'):
        drv.do_setup(self.context)
    mock_os_path_exists.assert_has_calls([mock.call(self.configuration.nfs_shares_config)])
    mock_execute.assert_has_calls([mock.call('mount.nfs', check_exit_code=False, run_as_root=True)])
