Merge "Port test_nfs to Python 3"

This commit is contained in:
Jenkins 2015-08-27 16:14:20 +00:00 committed by Gerrit Code Review
commit 3b40049cc8
2 changed files with 14 additions and 17 deletions

View File

@ -16,7 +16,6 @@
import errno import errno
import os import os
import testtools
import mock import mock
from mox3 import mox as mox_lib from mox3 import mox as mox_lib
@ -1140,7 +1139,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_os_path_exists = self.mock_object(os.path, 'exists') mock_os_path_exists = self.mock_object(os.path, 'exists')
with testtools.ExpectedException(exception.NfsException, with self.assertRaisesRegex(exception.NfsException,
".*no NFS config file configured.*"): ".*no NFS config file configured.*"):
drv.do_setup(self.context) drv.do_setup(self.context)
@ -1154,7 +1153,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_os_path_exists = self.mock_object(os.path, 'exists') mock_os_path_exists = self.mock_object(os.path, 'exists')
mock_os_path_exists.return_value = False mock_os_path_exists.return_value = False
with testtools.ExpectedException(exception.NfsException, with self.assertRaisesRegex(exception.NfsException,
"NFS config file.*doesn't exist"): "NFS config file.*doesn't exist"):
drv.do_setup(self.context) drv.do_setup(self.context)
@ -1170,8 +1169,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_os_path_exists = self.mock_object(os.path, 'exists') mock_os_path_exists = self.mock_object(os.path, 'exists')
mock_os_path_exists.return_value = True mock_os_path_exists.return_value = True
with testtools.ExpectedException( with self.assertRaisesRegex(exception.InvalidConfigurationValue,
exception.InvalidConfigurationValue,
".*'nfs_oversub_ratio' invalid.*"): ".*'nfs_oversub_ratio' invalid.*"):
drv.do_setup(self.context) drv.do_setup(self.context)
@ -1205,8 +1203,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_os_path_exists = self.mock_object(os.path, 'exists') mock_os_path_exists = self.mock_object(os.path, 'exists')
mock_os_path_exists.return_value = True mock_os_path_exists.return_value = True
with testtools.ExpectedException( with self.assertRaisesRegex(exception.InvalidConfigurationValue,
exception.InvalidConfigurationValue,
".*'nfs_used_ratio' invalid.*"): ".*'nfs_used_ratio' invalid.*"):
drv.do_setup(self.context) drv.do_setup(self.context)
@ -1222,8 +1219,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_os_path_exists = self.mock_object(os.path, 'exists') mock_os_path_exists = self.mock_object(os.path, 'exists')
mock_os_path_exists.return_value = True mock_os_path_exists.return_value = True
with testtools.ExpectedException( with self.assertRaisesRegex(exception.InvalidConfigurationValue,
exception.InvalidConfigurationValue,
".*'nfs_used_ratio' invalid.*"): ".*'nfs_used_ratio' invalid.*"):
drv.do_setup(self.context) drv.do_setup(self.context)
@ -1259,8 +1255,8 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_execute.side_effect = OSError( mock_execute.side_effect = OSError(
errno.ENOENT, 'No such file or directory.') errno.ENOENT, 'No such file or directory.')
with testtools.ExpectedException( with self.assertRaisesRegex(exception.NfsException,
exception.NfsException, 'mount.nfs is not installed'): 'mount.nfs is not installed'):
drv.do_setup(self.context) drv.do_setup(self.context)
mock_os_path_exists.assert_has_calls( mock_os_path_exists.assert_has_calls(
@ -1284,7 +1280,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_execute.side_effect = OSError( mock_execute.side_effect = OSError(
errno.EPERM, 'Operation... BROKEN') errno.EPERM, 'Operation... BROKEN')
with testtools.ExpectedException(OSError, '.*Operation... BROKEN'): with self.assertRaisesRegex(OSError, '.*Operation... BROKEN'):
drv.do_setup(self.context) drv.do_setup(self.context)
mock_os_path_exists.assert_has_calls( mock_os_path_exists.assert_has_calls(

View File

@ -76,6 +76,7 @@ commands =
cinder.tests.unit.test_ibm_xiv_ds8k \ cinder.tests.unit.test_ibm_xiv_ds8k \
cinder.tests.unit.test_infortrend_cli \ cinder.tests.unit.test_infortrend_cli \
cinder.tests.unit.test_netapp_nfs \ cinder.tests.unit.test_netapp_nfs \
cinder.tests.unit.test_nfs \
cinder.tests.unit.test_nimble \ cinder.tests.unit.test_nimble \
cinder.tests.unit.test_qos_specs \ cinder.tests.unit.test_qos_specs \
cinder.tests.unit.test_quota \ cinder.tests.unit.test_quota \