Merge "Replace assertRaisesRegexp with assertRaisesRegex"

This commit is contained in:
Jenkins 2017-05-22 17:44:19 +00:00 committed by Gerrit Code Review
commit b017242c0b
13 changed files with 109 additions and 109 deletions

View File

@ -62,14 +62,14 @@ class TestSchemas(test_base.MuranoTestCase):
dummy_error = client.RemoteError(exc_type=exc_type,
value='dummy_value')
mock_rpc.engine().generate_schema.side_effect = dummy_error
with self.assertRaisesRegexp(exc.HTTPNotFound,
dummy_error.value):
with self.assertRaisesRegex(exc.HTTPNotFound,
dummy_error.value):
self.controller.get_schema(mock_request, 'test_class')
# Test exception handling for miscellaneous exception type.
dummy_error = client.RemoteError(exc_type='TestExcType',
value='dummy_value')
mock_rpc.engine().generate_schema.side_effect = dummy_error
with self.assertRaisesRegexp(client.RemoteError,
dummy_error.value):
with self.assertRaisesRegex(client.RemoteError,
dummy_error.value):
self.controller.get_schema(mock_request, 'test_class')

View File

@ -214,8 +214,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
for state in illegal_states:
mock_envs.EnvironmentServices.get_status.return_value = state
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_msg):
self.sessions_controller.configure(mock_request, 'test_env_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -229,8 +229,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
'access session <SessionId {1}>.'\
.format(mock_request.context.user, 'test_sess_id')
with self.assertRaisesRegexp(exc.HTTPUnauthorized,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPUnauthorized,
expected_error_msg):
self.sessions_controller.show(mock_request, None, 'test_sess_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -247,8 +247,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
' has been updated or updating right now with'\
' other session'.format('test_sess_id')
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_msg):
self.sessions_controller.show(mock_request, None, 'test_sess_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -262,8 +262,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
'access session <SessionId {1}>.'\
.format(mock_request.context.user, 'test_sess_id')
with self.assertRaisesRegexp(exc.HTTPUnauthorized,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPUnauthorized,
expected_error_msg):
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -281,8 +281,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
'state and could not be deleted'\
.format('test_sess_id')
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_msg):
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -297,8 +297,8 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
' has been updated or updating right now with'\
' other session'.format('test_sess_id')
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_msg):
self.sessions_controller.deploy(mock_request, None, 'test_sess_id')
@mock.patch('murano.api.v1.sessions.check_session')
@ -321,7 +321,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
mock_session = mock.MagicMock(state=state)
mock_db_session.get_session().query().get.return_value =\
mock_session
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_msg):
self.sessions_controller.deploy(
mock_request, None, 'test_sess_id')

View File

@ -217,7 +217,7 @@ class TestManage(test_base.MuranoWithDBTestCase):
def test_main_except_runtime_error(self, mock_conf):
mock_conf.side_effect = RuntimeError
with self.assertRaisesRegexp(SystemExit, 'ERROR:'):
with self.assertRaisesRegex(SystemExit, 'ERROR:'):
manage.main()
@mock.patch('murano.cmd.manage.CONF')
@ -226,5 +226,5 @@ class TestManage(test_base.MuranoWithDBTestCase):
expected_err_msg = "murano-manage command failed:"
with self.assertRaisesRegexp(SystemExit, expected_err_msg):
with self.assertRaisesRegex(SystemExit, expected_err_msg):
manage.main()

View File

@ -194,8 +194,8 @@ class MQClientTest(base.MuranoTestCase):
queue_arguments={})
def test_declare_except_runtime_error(self):
with self.assertRaisesRegexp(RuntimeError,
'Not connected to RabbitMQ'):
with self.assertRaisesRegex(RuntimeError,
'Not connected to RabbitMQ'):
self.ssl_client.declare(None)
@mock.patch('murano.common.messaging.mqclient.kombu')
@ -212,8 +212,8 @@ class MQClientTest(base.MuranoTestCase):
body=jsonutils.dumps('test_message'), message_id='3')
def test_send_except_runtime_error(self):
with self.assertRaisesRegexp(RuntimeError,
'Not connected to RabbitMQ'):
with self.assertRaisesRegex(RuntimeError,
'Not connected to RabbitMQ'):
self.ssl_client.send(None, None)
@mock.patch('murano.common.messaging.mqclient.subscription')
@ -224,6 +224,6 @@ class MQClientTest(base.MuranoTestCase):
self.ssl_client._connection, 'test_queue', 2)
def test_open_except_runtime_error(self):
with self.assertRaisesRegexp(RuntimeError,
'Not connected to RabbitMQ'):
with self.assertRaisesRegex(RuntimeError,
'Not connected to RabbitMQ'):
self.ssl_client.open(None)

View File

@ -222,8 +222,8 @@ class TestAgent(base.MuranoTestCase):
expected_error_msg = 'The murano-agent did not respond within 1 '\
'seconds'
with self.assertRaisesRegexp(exceptions.TimeoutException,
expected_error_msg):
with self.assertRaisesRegex(exceptions.TimeoutException,
expected_error_msg):
self.agent.call(template, self.resources, None)
@mock.patch('murano.engine.system.agent.datetime')

View File

@ -98,8 +98,8 @@ class TestMistralClient(base.MuranoTestCase):
expected_error_msg = 'Mistral execution completed with ERROR.'\
' Execution id: {0}. Output: {1}'\
.format(mock_execution.id, mock_execution.output)
with self.assertRaisesRegexp(workflowclient.MistralError,
expected_error_msg):
with self.assertRaisesRegex(workflowclient.MistralError,
expected_error_msg):
mc.run(run_name, timeout)
def test_run_except_timeout_error(self):
@ -114,8 +114,8 @@ class TestMistralClient(base.MuranoTestCase):
expected_error_msg = 'Mistral run timed out. Execution id: {0}.'\
.format(mock_execution.id)
with self.assertRaisesRegexp(workflowclient.MistralError,
expected_error_msg):
with self.assertRaisesRegex(workflowclient.MistralError,
expected_error_msg):
mc.run(run_name, timeout)
def test_run_with_immediate_timeout(self):

View File

@ -190,8 +190,8 @@ class TestPackageCache(base.MuranoTestCase):
self.loader.import_fixation_table({fqn: [test_version]})
self.loader.register_package(package)
with self.assertRaisesRegexp(dsl_exceptions.NoPackageFound,
expected_error_msg):
with self.assertRaisesRegex(dsl_exceptions.NoPackageFound,
expected_error_msg):
for spec in invalid_specs:
self.loader.load_package('test_package_name', spec)
@ -324,8 +324,8 @@ class TestPackageCache(base.MuranoTestCase):
for class_ in package.classes:
expected_error_msg = 'Package for class "{0}" is not found'\
.format(class_)
with self.assertRaisesRegexp(dsl_exceptions.NoPackageForClassFound,
expected_error_msg):
with self.assertRaisesRegex(dsl_exceptions.NoPackageForClassFound,
expected_error_msg):
for spec in invalid_specs:
self.loader.load_class_package(class_, spec)
@ -371,7 +371,7 @@ class TestPackageCache(base.MuranoTestCase):
def test_get_definition_except_lookup_error(self, mock_log):
self.loader.client.packages.filter.return_value = []
with self.assertRaisesRegexp(LookupError, None):
with self.assertRaisesRegex(LookupError, None):
self.loader._get_definition({})
mock_log.debug.assert_called_once_with(
@ -382,7 +382,7 @@ class TestPackageCache(base.MuranoTestCase):
self.loader.client.packages.filter.side_effect =\
muranoclient_exc.HTTPException
with self.assertRaisesRegexp(LookupError, None):
with self.assertRaisesRegex(LookupError, None):
self.loader._get_definition({})
mock_log.debug.assert_called_once_with(
@ -445,8 +445,8 @@ class TestPackageCache(base.MuranoTestCase):
muranoclient_exc.HTTPException
expected_error_msg = 'Error loading package id {0}:'.format(package.id)
with self.assertRaisesRegexp(pkg_exc.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(pkg_exc.PackageLoadError,
expected_error_msg):
self.loader._get_package_by_definition(package)
@testtools.skipIf(os.name == 'nt', "Doesn't work on Windows")
@ -475,8 +475,8 @@ class TestPackageCache(base.MuranoTestCase):
expected_error_msg = 'Unable to extract package data for {0}'\
.format(package.id)
with self.assertRaisesRegexp(pkg_exc.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(pkg_exc.PackageLoadError,
expected_error_msg):
self.loader._get_package_by_definition(package)
def test_try_cleanup_cache_with_null_package_directory(self):

View File

@ -133,7 +133,7 @@ class TestHotPackage(test_base.MuranoTestCase):
self.assertEqual(expected_result, result['templateParameters'])
def test_translate_param_to_contract_with_inappropriate_value(self):
self.assertRaisesRegexp(
self.assertRaisesRegex(
ValueError,
'Unsupported parameter type',
murano.packages.hot_package.HotPackage.
@ -149,7 +149,7 @@ class TestHotPackage(test_base.MuranoTestCase):
def test_get_class_name_with_invalid_template_name(self):
hot_package = self._get_hot_package(self.test_dirs[0])
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.PackageClassLoadError,
'Class not defined in this package',
hot_package.get_class,
@ -157,7 +157,7 @@ class TestHotPackage(test_base.MuranoTestCase):
def test_get_class_name_with_invalid_template_format(self):
hot_package = self._get_hot_package(self.test_dirs[1])
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.PackageFormatError,
'Not a HOT template',
hot_package.get_class,
@ -184,14 +184,14 @@ class TestHotPackage(test_base.MuranoTestCase):
def test_translate_ui_with_nonexistent_template(self):
hot_package = self._get_hot_package(self.test_dirs[2])
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.PackageClassLoadError,
'File with class definition not found',
hot_package._translate_ui)
def test_translate_class_with_nonexistent_template(self):
hot_package = self._get_hot_package(self.test_dirs[2])
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.PackageClassLoadError,
'File with class definition not found',
hot_package._translate_class)

View File

@ -132,8 +132,8 @@ class TestLoadUtils(test_base.MuranoTestCase):
self._create_temp_zip_file(zip_path, manifest_path)
expected_error_msg = "Unsupported format {0}".format(test_format)
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
with load_utils.load_from_file(archive_path=zip_path,
target_dir=target_dir,
drop_dir=True):
@ -143,8 +143,8 @@ class TestLoadUtils(test_base.MuranoTestCase):
def test_load_from_file_with_invalid_archive_path(self):
expected_error_msg = "Unable to find package file"
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
with load_utils.load_from_file('invalid file path'):
pass
@ -153,8 +153,8 @@ class TestLoadUtils(test_base.MuranoTestCase):
mock_os.listdir = mock.MagicMock(return_value=True)
temp_file = self._create_temp_file()
expected_error_msg = "Target directory is not empty"
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
this_dir = os.path.dirname(os.path.realpath(__file__))
with load_utils.load_from_file(temp_file.name,
target_dir=this_dir):
@ -164,8 +164,8 @@ class TestLoadUtils(test_base.MuranoTestCase):
temp_file = self._create_temp_file()
expected_error_msg = "Uploaded file {0} is not a zip archive".\
format(temp_file.name)
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
with load_utils.load_from_file(temp_file.name):
pass
@ -177,8 +177,8 @@ class TestLoadUtils(test_base.MuranoTestCase):
mock_zipfile.is_zipfile = mock.MagicMock(
side_effect=ValueError(test_error_msg))
temp_file = self._create_temp_file()
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
with load_utils.load_from_file(temp_file.name):
pass
mock_zipfile.is_zipfile.assert_called_once_with(
@ -186,15 +186,15 @@ class TestLoadUtils(test_base.MuranoTestCase):
def test_load_from_dir_without_source_directory(self):
expected_error_msg = 'Invalid package directory'
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
load_utils.load_from_dir('random_test_directory')
def test_load_from_dir_with_invalid_source_directory(self):
source_directory = self._create_temp_dir()
expected_error_msg = 'Unable to find package manifest'
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
load_utils.load_from_dir(source_directory)
@mock.patch('murano.packages.load_utils.os.path.isfile')
@ -204,7 +204,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
random_filename = ''.join(random.choice(string.ascii_lowercase)
for i in range(20))
expected_error_msg = 'Unable to load due to'
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_msg):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_msg):
load_utils.load_from_dir(source_directory,
filename=random_filename)

View File

@ -56,8 +56,8 @@ class TestPackageBase(test_base.MuranoTestCase):
shutil.rmtree(cls.source_directory)
def test_create_package_base_without_full_name(self):
with self.assertRaisesRegexp(exceptions.PackageFormatError,
'FullName is not specified'):
with self.assertRaisesRegex(exceptions.PackageFormatError,
'FullName is not specified'):
package_base.PackageBase('test_format',
'test_runtime_version',
'test_source_directory',
@ -67,8 +67,8 @@ class TestPackageBase(test_base.MuranoTestCase):
full_names = ['.invalid_name_1', 'invalid..name..2', 'invalid name 3']
for full_name in full_names:
expected_error_message = 'Invalid FullName {0}'.format(full_name)
with self.assertRaisesRegexp(exceptions.PackageFormatError,
expected_error_message):
with self.assertRaisesRegex(exceptions.PackageFormatError,
expected_error_message):
package_base.PackageBase('test_format',
'test_runtime_version',
'test_source_directory',
@ -76,9 +76,9 @@ class TestPackageBase(test_base.MuranoTestCase):
def test_create_package_base_with_invalid_type(self):
package_type = 'Invalid'
with self.assertRaisesRegexp(exceptions.PackageFormatError,
'Invalid package Type {0}'
.format(package_type)):
with self.assertRaisesRegex(exceptions.PackageFormatError,
'Invalid package Type {0}'
.format(package_type)):
package_base.PackageBase('test_format',
'test_runtime_version',
'test_source_directory',
@ -86,19 +86,19 @@ class TestPackageBase(test_base.MuranoTestCase):
'Type': package_type})
def test_requirements_negative(self):
with self.assertRaisesRegexp(NotImplementedError, None):
with self.assertRaisesRegex(NotImplementedError, None):
self.package_base.requirements
def test_classes_negative(self):
with self.assertRaisesRegexp(NotImplementedError, None):
with self.assertRaisesRegex(NotImplementedError, None):
self.package_base.classes
def test_get_class_negative(self):
with self.assertRaisesRegexp(NotImplementedError, None):
with self.assertRaisesRegex(NotImplementedError, None):
self.package_base.get_class(None)
def test_ui_negative(self):
with self.assertRaisesRegexp(NotImplementedError, None):
with self.assertRaisesRegex(NotImplementedError, None):
self.package_base.ui
def test_full_name(self):
@ -144,8 +144,8 @@ class TestPackageBase(test_base.MuranoTestCase):
expected_error_message = 'Unable to load logo'
self.package_base._logo = ''.join(random.choice(string.ascii_letters)
for _ in range(10))
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_message):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_message):
self.package_base.logo
self.package_base._logo = self.mock_manifest['Logo']
@ -153,8 +153,8 @@ class TestPackageBase(test_base.MuranoTestCase):
what=mock.MagicMock(return_value='xyz'))
def test_load_image_with_invalid_extension(self, mock_imghdr):
expected_error_message = 'Unsupported Format.'
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_message):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_message):
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
full_path = os.path.join(self.package_base._source_directory,
'logo.xyz')
@ -167,8 +167,8 @@ class TestPackageBase(test_base.MuranoTestCase):
mock_os.stat.return_value = mock.MagicMock(st_size=5000 * 1024)
mock_os.isfile = mock.MagicMock(return_value=True)
expected_error_message = 'Max allowed size is {0}'.format(500 * 1024)
with self.assertRaisesRegexp(exceptions.PackageLoadError,
expected_error_message):
with self.assertRaisesRegex(exceptions.PackageLoadError,
expected_error_message):
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
def test_meta(self):

View File

@ -190,7 +190,7 @@ class TestActions(test_base.MuranoTestCase):
test_action_id = 'test_action_id'
test_session = mock.MagicMock(description=[])
with self.assertRaisesRegexp(LookupError, 'Action is not found'):
with self.assertRaisesRegex(LookupError, 'Action is not found'):
actions.ActionServices.execute(test_action_id, test_session,
None, None, None)
@ -210,8 +210,8 @@ class TestActions(test_base.MuranoTestCase):
}]
test_session = mock.MagicMock(description=test_description)
with self.assertRaisesRegexp(ValueError,
'Cannot execute disabled action'):
with self.assertRaisesRegex(ValueError,
'Cannot execute disabled action'):
actions.ActionServices.execute(test_action_id, test_session,
None, None, None)

View File

@ -694,8 +694,8 @@ class TestHeatStack(base.MuranoTestCase):
# Else EnvironmentError should be thrown.
expected_error_msg = "Unexpected stack state {0}"\
.format('NOT_FOUND')
with self.assertRaisesRegexp(EnvironmentError,
expected_error_msg):
with self.assertRaisesRegex(EnvironmentError,
expected_error_msg):
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
@mock.patch.object(heat_stack, 'eventlet')
@ -705,8 +705,8 @@ class TestHeatStack(base.MuranoTestCase):
hs = heat_stack.HeatStack('test-stack', None)
hs._client.stacks.get.side_effect = Exception('test_exception_msg')
with self.assertRaisesRegexp(Exception,
'test_exception_msg'):
with self.assertRaisesRegex(Exception,
'test_exception_msg'):
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
expected_calls = [mock.call.sleep(2), mock.call.sleep(4),
@ -725,6 +725,6 @@ class TestHeatStack(base.MuranoTestCase):
expected_error_msg = "Unexpected stack state {0}: {1}"\
.format('UNEXPECTED_STATUS', 'test_reason')
with self.assertRaisesRegexp(EnvironmentError,
expected_error_msg):
with self.assertRaisesRegex(EnvironmentError,
expected_error_msg):
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')

View File

@ -45,8 +45,8 @@ class TestUtils(test_base.MuranoTestCase):
expected_error_message = 'Environment with id {env_id} not found'\
.format(env_id=test_env_id)
with self.assertRaisesRegexp(exc.HTTPNotFound,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPNotFound,
expected_error_message):
utils.check_env(mock_request, test_env_id)
@mock.patch('murano.utils.db_session')
@ -60,16 +60,16 @@ class TestUtils(test_base.MuranoTestCase):
expected_error_message = 'User is not authorized to access these '\
'tenant resources'
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_message):
utils.check_env(mock_request, mock_env.environment_id)
def test_check_session_with_null_session(self):
"""Test check session with null session throws exception."""
expected_error_message = 'Session <SessionId {id}> is not found'\
.format(id=None)
with self.assertRaisesRegexp(exc.HTTPNotFound,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPNotFound,
expected_error_message):
utils.check_session(None, None, None, None)
@mock.patch('murano.utils.check_env')
@ -82,8 +82,8 @@ class TestUtils(test_base.MuranoTestCase):
'with Environment <EnvId {environment_id}>'\
.format(session_id=mock_session.session_id,
environment_id=environment_id)
with self.assertRaisesRegexp(exc.HTTPBadRequest,
expected_error_msg):
with self.assertRaisesRegex(exc.HTTPBadRequest,
expected_error_msg):
utils.check_session(None, environment_id, mock_session,
mock_session.session_id)
@ -95,8 +95,8 @@ class TestUtils(test_base.MuranoTestCase):
mock_request = mock.MagicMock(context=dummy_context)
expected_error_message = 'X-Configuration-Session header which '\
'indicates to the session is missed'
with self.assertRaisesRegexp(exc.HTTPBadRequest,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPBadRequest,
expected_error_message):
self._test_verify_session(mock_request)
@mock.patch('murano.utils.db_session')
@ -108,8 +108,8 @@ class TestUtils(test_base.MuranoTestCase):
mock_db_session.get_session().query().get.return_value = None
expected_error_message = 'Session <SessionId {0}> is not found'\
.format(mock_request.context.session)
with self.assertRaisesRegexp(exc.HTTPNotFound,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPNotFound,
expected_error_message):
self._test_verify_session(mock_request)
@mock.patch('murano.utils.db_session')
@ -123,8 +123,8 @@ class TestUtils(test_base.MuranoTestCase):
mock_env_template
expected_error_message = 'User is not authorized to access this'\
' tenant resources'
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_message):
self._test_verify_env_template(mock_request, None)
@mock.patch('murano.utils.db_session')
@ -133,8 +133,8 @@ class TestUtils(test_base.MuranoTestCase):
mock_db_session.get_session().query().get.return_value = None
expected_error_message = 'Environment Template with id {id} not found'\
.format(id='test_env_template_id')
with self.assertRaisesRegexp(exc.HTTPNotFound,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPNotFound,
expected_error_message):
self._test_verify_env_template(None, 'test_env_template_id')
@utils.verify_env_template
@ -157,8 +157,8 @@ class TestUtils(test_base.MuranoTestCase):
'environment has been updated or '\
'updating right now with other session'\
.format(mock_request.context.session)
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_message):
self._test_verify_session(mock_request)
@mock.patch('murano.utils.sessions.SessionServices.validate')
@ -176,8 +176,8 @@ class TestUtils(test_base.MuranoTestCase):
expected_error_message = 'Session <SessionId {0}> is already in '\
'deployment state'\
.format(mock_request.context.session)
with self.assertRaisesRegexp(exc.HTTPForbidden,
expected_error_message):
with self.assertRaisesRegex(exc.HTTPForbidden,
expected_error_message):
self._test_verify_session(mock_request)
@utils.verify_session