Merge "Replace assertRaisesRegexp with assertRaisesRegex"
This commit is contained in:
commit
b017242c0b
@ -62,7 +62,7 @@ class TestSchemas(test_base.MuranoTestCase):
|
|||||||
dummy_error = client.RemoteError(exc_type=exc_type,
|
dummy_error = client.RemoteError(exc_type=exc_type,
|
||||||
value='dummy_value')
|
value='dummy_value')
|
||||||
mock_rpc.engine().generate_schema.side_effect = dummy_error
|
mock_rpc.engine().generate_schema.side_effect = dummy_error
|
||||||
with self.assertRaisesRegexp(exc.HTTPNotFound,
|
with self.assertRaisesRegex(exc.HTTPNotFound,
|
||||||
dummy_error.value):
|
dummy_error.value):
|
||||||
self.controller.get_schema(mock_request, 'test_class')
|
self.controller.get_schema(mock_request, 'test_class')
|
||||||
|
|
||||||
@ -70,6 +70,6 @@ class TestSchemas(test_base.MuranoTestCase):
|
|||||||
dummy_error = client.RemoteError(exc_type='TestExcType',
|
dummy_error = client.RemoteError(exc_type='TestExcType',
|
||||||
value='dummy_value')
|
value='dummy_value')
|
||||||
mock_rpc.engine().generate_schema.side_effect = dummy_error
|
mock_rpc.engine().generate_schema.side_effect = dummy_error
|
||||||
with self.assertRaisesRegexp(client.RemoteError,
|
with self.assertRaisesRegex(client.RemoteError,
|
||||||
dummy_error.value):
|
dummy_error.value):
|
||||||
self.controller.get_schema(mock_request, 'test_class')
|
self.controller.get_schema(mock_request, 'test_class')
|
||||||
|
@ -214,7 +214,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
for state in illegal_states:
|
for state in illegal_states:
|
||||||
mock_envs.EnvironmentServices.get_status.return_value = state
|
mock_envs.EnvironmentServices.get_status.return_value = state
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.configure(mock_request, 'test_env_id')
|
self.sessions_controller.configure(mock_request, 'test_env_id')
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
'access session <SessionId {1}>.'\
|
'access session <SessionId {1}>.'\
|
||||||
.format(mock_request.context.user, 'test_sess_id')
|
.format(mock_request.context.user, 'test_sess_id')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPUnauthorized,
|
with self.assertRaisesRegex(exc.HTTPUnauthorized,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.show(mock_request, None, 'test_sess_id')
|
self.sessions_controller.show(mock_request, None, 'test_sess_id')
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
' has been updated or updating right now with'\
|
' has been updated or updating right now with'\
|
||||||
' other session'.format('test_sess_id')
|
' other session'.format('test_sess_id')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.show(mock_request, None, 'test_sess_id')
|
self.sessions_controller.show(mock_request, None, 'test_sess_id')
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
'access session <SessionId {1}>.'\
|
'access session <SessionId {1}>.'\
|
||||||
.format(mock_request.context.user, 'test_sess_id')
|
.format(mock_request.context.user, 'test_sess_id')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPUnauthorized,
|
with self.assertRaisesRegex(exc.HTTPUnauthorized,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
|
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
'state and could not be deleted'\
|
'state and could not be deleted'\
|
||||||
.format('test_sess_id')
|
.format('test_sess_id')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
|
self.sessions_controller.delete(mock_request, None, 'test_sess_id')
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
' has been updated or updating right now with'\
|
' has been updated or updating right now with'\
|
||||||
' other session'.format('test_sess_id')
|
' other session'.format('test_sess_id')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.deploy(mock_request, None, 'test_sess_id')
|
self.sessions_controller.deploy(mock_request, None, 'test_sess_id')
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ class TestSessionsApi(tb.ControllerTest, tb.MuranoApiTestCase):
|
|||||||
mock_session = mock.MagicMock(state=state)
|
mock_session = mock.MagicMock(state=state)
|
||||||
mock_db_session.get_session().query().get.return_value =\
|
mock_db_session.get_session().query().get.return_value =\
|
||||||
mock_session
|
mock_session
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.sessions_controller.deploy(
|
self.sessions_controller.deploy(
|
||||||
mock_request, None, 'test_sess_id')
|
mock_request, None, 'test_sess_id')
|
||||||
|
@ -217,7 +217,7 @@ class TestManage(test_base.MuranoWithDBTestCase):
|
|||||||
def test_main_except_runtime_error(self, mock_conf):
|
def test_main_except_runtime_error(self, mock_conf):
|
||||||
mock_conf.side_effect = RuntimeError
|
mock_conf.side_effect = RuntimeError
|
||||||
|
|
||||||
with self.assertRaisesRegexp(SystemExit, 'ERROR:'):
|
with self.assertRaisesRegex(SystemExit, 'ERROR:'):
|
||||||
manage.main()
|
manage.main()
|
||||||
|
|
||||||
@mock.patch('murano.cmd.manage.CONF')
|
@mock.patch('murano.cmd.manage.CONF')
|
||||||
@ -226,5 +226,5 @@ class TestManage(test_base.MuranoWithDBTestCase):
|
|||||||
|
|
||||||
expected_err_msg = "murano-manage command failed:"
|
expected_err_msg = "murano-manage command failed:"
|
||||||
|
|
||||||
with self.assertRaisesRegexp(SystemExit, expected_err_msg):
|
with self.assertRaisesRegex(SystemExit, expected_err_msg):
|
||||||
manage.main()
|
manage.main()
|
||||||
|
@ -194,7 +194,7 @@ class MQClientTest(base.MuranoTestCase):
|
|||||||
queue_arguments={})
|
queue_arguments={})
|
||||||
|
|
||||||
def test_declare_except_runtime_error(self):
|
def test_declare_except_runtime_error(self):
|
||||||
with self.assertRaisesRegexp(RuntimeError,
|
with self.assertRaisesRegex(RuntimeError,
|
||||||
'Not connected to RabbitMQ'):
|
'Not connected to RabbitMQ'):
|
||||||
self.ssl_client.declare(None)
|
self.ssl_client.declare(None)
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ class MQClientTest(base.MuranoTestCase):
|
|||||||
body=jsonutils.dumps('test_message'), message_id='3')
|
body=jsonutils.dumps('test_message'), message_id='3')
|
||||||
|
|
||||||
def test_send_except_runtime_error(self):
|
def test_send_except_runtime_error(self):
|
||||||
with self.assertRaisesRegexp(RuntimeError,
|
with self.assertRaisesRegex(RuntimeError,
|
||||||
'Not connected to RabbitMQ'):
|
'Not connected to RabbitMQ'):
|
||||||
self.ssl_client.send(None, None)
|
self.ssl_client.send(None, None)
|
||||||
|
|
||||||
@ -224,6 +224,6 @@ class MQClientTest(base.MuranoTestCase):
|
|||||||
self.ssl_client._connection, 'test_queue', 2)
|
self.ssl_client._connection, 'test_queue', 2)
|
||||||
|
|
||||||
def test_open_except_runtime_error(self):
|
def test_open_except_runtime_error(self):
|
||||||
with self.assertRaisesRegexp(RuntimeError,
|
with self.assertRaisesRegex(RuntimeError,
|
||||||
'Not connected to RabbitMQ'):
|
'Not connected to RabbitMQ'):
|
||||||
self.ssl_client.open(None)
|
self.ssl_client.open(None)
|
||||||
|
@ -222,7 +222,7 @@ class TestAgent(base.MuranoTestCase):
|
|||||||
|
|
||||||
expected_error_msg = 'The murano-agent did not respond within 1 '\
|
expected_error_msg = 'The murano-agent did not respond within 1 '\
|
||||||
'seconds'
|
'seconds'
|
||||||
with self.assertRaisesRegexp(exceptions.TimeoutException,
|
with self.assertRaisesRegex(exceptions.TimeoutException,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.agent.call(template, self.resources, None)
|
self.agent.call(template, self.resources, None)
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class TestMistralClient(base.MuranoTestCase):
|
|||||||
expected_error_msg = 'Mistral execution completed with ERROR.'\
|
expected_error_msg = 'Mistral execution completed with ERROR.'\
|
||||||
' Execution id: {0}. Output: {1}'\
|
' Execution id: {0}. Output: {1}'\
|
||||||
.format(mock_execution.id, mock_execution.output)
|
.format(mock_execution.id, mock_execution.output)
|
||||||
with self.assertRaisesRegexp(workflowclient.MistralError,
|
with self.assertRaisesRegex(workflowclient.MistralError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
mc.run(run_name, timeout)
|
mc.run(run_name, timeout)
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class TestMistralClient(base.MuranoTestCase):
|
|||||||
|
|
||||||
expected_error_msg = 'Mistral run timed out. Execution id: {0}.'\
|
expected_error_msg = 'Mistral run timed out. Execution id: {0}.'\
|
||||||
.format(mock_execution.id)
|
.format(mock_execution.id)
|
||||||
with self.assertRaisesRegexp(workflowclient.MistralError,
|
with self.assertRaisesRegex(workflowclient.MistralError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
mc.run(run_name, timeout)
|
mc.run(run_name, timeout)
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class TestPackageCache(base.MuranoTestCase):
|
|||||||
self.loader.import_fixation_table({fqn: [test_version]})
|
self.loader.import_fixation_table({fqn: [test_version]})
|
||||||
self.loader.register_package(package)
|
self.loader.register_package(package)
|
||||||
|
|
||||||
with self.assertRaisesRegexp(dsl_exceptions.NoPackageFound,
|
with self.assertRaisesRegex(dsl_exceptions.NoPackageFound,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
for spec in invalid_specs:
|
for spec in invalid_specs:
|
||||||
self.loader.load_package('test_package_name', spec)
|
self.loader.load_package('test_package_name', spec)
|
||||||
@ -324,7 +324,7 @@ class TestPackageCache(base.MuranoTestCase):
|
|||||||
for class_ in package.classes:
|
for class_ in package.classes:
|
||||||
expected_error_msg = 'Package for class "{0}" is not found'\
|
expected_error_msg = 'Package for class "{0}" is not found'\
|
||||||
.format(class_)
|
.format(class_)
|
||||||
with self.assertRaisesRegexp(dsl_exceptions.NoPackageForClassFound,
|
with self.assertRaisesRegex(dsl_exceptions.NoPackageForClassFound,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
for spec in invalid_specs:
|
for spec in invalid_specs:
|
||||||
self.loader.load_class_package(class_, spec)
|
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):
|
def test_get_definition_except_lookup_error(self, mock_log):
|
||||||
self.loader.client.packages.filter.return_value = []
|
self.loader.client.packages.filter.return_value = []
|
||||||
|
|
||||||
with self.assertRaisesRegexp(LookupError, None):
|
with self.assertRaisesRegex(LookupError, None):
|
||||||
self.loader._get_definition({})
|
self.loader._get_definition({})
|
||||||
|
|
||||||
mock_log.debug.assert_called_once_with(
|
mock_log.debug.assert_called_once_with(
|
||||||
@ -382,7 +382,7 @@ class TestPackageCache(base.MuranoTestCase):
|
|||||||
self.loader.client.packages.filter.side_effect =\
|
self.loader.client.packages.filter.side_effect =\
|
||||||
muranoclient_exc.HTTPException
|
muranoclient_exc.HTTPException
|
||||||
|
|
||||||
with self.assertRaisesRegexp(LookupError, None):
|
with self.assertRaisesRegex(LookupError, None):
|
||||||
self.loader._get_definition({})
|
self.loader._get_definition({})
|
||||||
|
|
||||||
mock_log.debug.assert_called_once_with(
|
mock_log.debug.assert_called_once_with(
|
||||||
@ -445,7 +445,7 @@ class TestPackageCache(base.MuranoTestCase):
|
|||||||
muranoclient_exc.HTTPException
|
muranoclient_exc.HTTPException
|
||||||
|
|
||||||
expected_error_msg = 'Error loading package id {0}:'.format(package.id)
|
expected_error_msg = 'Error loading package id {0}:'.format(package.id)
|
||||||
with self.assertRaisesRegexp(pkg_exc.PackageLoadError,
|
with self.assertRaisesRegex(pkg_exc.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.loader._get_package_by_definition(package)
|
self.loader._get_package_by_definition(package)
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ class TestPackageCache(base.MuranoTestCase):
|
|||||||
|
|
||||||
expected_error_msg = 'Unable to extract package data for {0}'\
|
expected_error_msg = 'Unable to extract package data for {0}'\
|
||||||
.format(package.id)
|
.format(package.id)
|
||||||
with self.assertRaisesRegexp(pkg_exc.PackageLoadError,
|
with self.assertRaisesRegex(pkg_exc.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
self.loader._get_package_by_definition(package)
|
self.loader._get_package_by_definition(package)
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class TestHotPackage(test_base.MuranoTestCase):
|
|||||||
self.assertEqual(expected_result, result['templateParameters'])
|
self.assertEqual(expected_result, result['templateParameters'])
|
||||||
|
|
||||||
def test_translate_param_to_contract_with_inappropriate_value(self):
|
def test_translate_param_to_contract_with_inappropriate_value(self):
|
||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegex(
|
||||||
ValueError,
|
ValueError,
|
||||||
'Unsupported parameter type',
|
'Unsupported parameter type',
|
||||||
murano.packages.hot_package.HotPackage.
|
murano.packages.hot_package.HotPackage.
|
||||||
@ -149,7 +149,7 @@ class TestHotPackage(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_get_class_name_with_invalid_template_name(self):
|
def test_get_class_name_with_invalid_template_name(self):
|
||||||
hot_package = self._get_hot_package(self.test_dirs[0])
|
hot_package = self._get_hot_package(self.test_dirs[0])
|
||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegex(
|
||||||
exceptions.PackageClassLoadError,
|
exceptions.PackageClassLoadError,
|
||||||
'Class not defined in this package',
|
'Class not defined in this package',
|
||||||
hot_package.get_class,
|
hot_package.get_class,
|
||||||
@ -157,7 +157,7 @@ class TestHotPackage(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_get_class_name_with_invalid_template_format(self):
|
def test_get_class_name_with_invalid_template_format(self):
|
||||||
hot_package = self._get_hot_package(self.test_dirs[1])
|
hot_package = self._get_hot_package(self.test_dirs[1])
|
||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegex(
|
||||||
exceptions.PackageFormatError,
|
exceptions.PackageFormatError,
|
||||||
'Not a HOT template',
|
'Not a HOT template',
|
||||||
hot_package.get_class,
|
hot_package.get_class,
|
||||||
@ -184,14 +184,14 @@ class TestHotPackage(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_translate_ui_with_nonexistent_template(self):
|
def test_translate_ui_with_nonexistent_template(self):
|
||||||
hot_package = self._get_hot_package(self.test_dirs[2])
|
hot_package = self._get_hot_package(self.test_dirs[2])
|
||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegex(
|
||||||
exceptions.PackageClassLoadError,
|
exceptions.PackageClassLoadError,
|
||||||
'File with class definition not found',
|
'File with class definition not found',
|
||||||
hot_package._translate_ui)
|
hot_package._translate_ui)
|
||||||
|
|
||||||
def test_translate_class_with_nonexistent_template(self):
|
def test_translate_class_with_nonexistent_template(self):
|
||||||
hot_package = self._get_hot_package(self.test_dirs[2])
|
hot_package = self._get_hot_package(self.test_dirs[2])
|
||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegex(
|
||||||
exceptions.PackageClassLoadError,
|
exceptions.PackageClassLoadError,
|
||||||
'File with class definition not found',
|
'File with class definition not found',
|
||||||
hot_package._translate_class)
|
hot_package._translate_class)
|
||||||
|
@ -132,7 +132,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
self._create_temp_zip_file(zip_path, manifest_path)
|
self._create_temp_zip_file(zip_path, manifest_path)
|
||||||
|
|
||||||
expected_error_msg = "Unsupported format {0}".format(test_format)
|
expected_error_msg = "Unsupported format {0}".format(test_format)
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
with load_utils.load_from_file(archive_path=zip_path,
|
with load_utils.load_from_file(archive_path=zip_path,
|
||||||
target_dir=target_dir,
|
target_dir=target_dir,
|
||||||
@ -143,7 +143,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_load_from_file_with_invalid_archive_path(self):
|
def test_load_from_file_with_invalid_archive_path(self):
|
||||||
expected_error_msg = "Unable to find package file"
|
expected_error_msg = "Unable to find package file"
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
with load_utils.load_from_file('invalid file path'):
|
with load_utils.load_from_file('invalid file path'):
|
||||||
pass
|
pass
|
||||||
@ -153,7 +153,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
mock_os.listdir = mock.MagicMock(return_value=True)
|
mock_os.listdir = mock.MagicMock(return_value=True)
|
||||||
temp_file = self._create_temp_file()
|
temp_file = self._create_temp_file()
|
||||||
expected_error_msg = "Target directory is not empty"
|
expected_error_msg = "Target directory is not empty"
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
this_dir = os.path.dirname(os.path.realpath(__file__))
|
this_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
with load_utils.load_from_file(temp_file.name,
|
with load_utils.load_from_file(temp_file.name,
|
||||||
@ -164,7 +164,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
temp_file = self._create_temp_file()
|
temp_file = self._create_temp_file()
|
||||||
expected_error_msg = "Uploaded file {0} is not a zip archive".\
|
expected_error_msg = "Uploaded file {0} is not a zip archive".\
|
||||||
format(temp_file.name)
|
format(temp_file.name)
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
with load_utils.load_from_file(temp_file.name):
|
with load_utils.load_from_file(temp_file.name):
|
||||||
pass
|
pass
|
||||||
@ -177,7 +177,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
mock_zipfile.is_zipfile = mock.MagicMock(
|
mock_zipfile.is_zipfile = mock.MagicMock(
|
||||||
side_effect=ValueError(test_error_msg))
|
side_effect=ValueError(test_error_msg))
|
||||||
temp_file = self._create_temp_file()
|
temp_file = self._create_temp_file()
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
with load_utils.load_from_file(temp_file.name):
|
with load_utils.load_from_file(temp_file.name):
|
||||||
pass
|
pass
|
||||||
@ -186,14 +186,14 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_load_from_dir_without_source_directory(self):
|
def test_load_from_dir_without_source_directory(self):
|
||||||
expected_error_msg = 'Invalid package directory'
|
expected_error_msg = 'Invalid package directory'
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
load_utils.load_from_dir('random_test_directory')
|
load_utils.load_from_dir('random_test_directory')
|
||||||
|
|
||||||
def test_load_from_dir_with_invalid_source_directory(self):
|
def test_load_from_dir_with_invalid_source_directory(self):
|
||||||
source_directory = self._create_temp_dir()
|
source_directory = self._create_temp_dir()
|
||||||
expected_error_msg = 'Unable to find package manifest'
|
expected_error_msg = 'Unable to find package manifest'
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
load_utils.load_from_dir(source_directory)
|
load_utils.load_from_dir(source_directory)
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class TestLoadUtils(test_base.MuranoTestCase):
|
|||||||
random_filename = ''.join(random.choice(string.ascii_lowercase)
|
random_filename = ''.join(random.choice(string.ascii_lowercase)
|
||||||
for i in range(20))
|
for i in range(20))
|
||||||
expected_error_msg = 'Unable to load due to'
|
expected_error_msg = 'Unable to load due to'
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
load_utils.load_from_dir(source_directory,
|
load_utils.load_from_dir(source_directory,
|
||||||
filename=random_filename)
|
filename=random_filename)
|
||||||
|
@ -56,7 +56,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
shutil.rmtree(cls.source_directory)
|
shutil.rmtree(cls.source_directory)
|
||||||
|
|
||||||
def test_create_package_base_without_full_name(self):
|
def test_create_package_base_without_full_name(self):
|
||||||
with self.assertRaisesRegexp(exceptions.PackageFormatError,
|
with self.assertRaisesRegex(exceptions.PackageFormatError,
|
||||||
'FullName is not specified'):
|
'FullName is not specified'):
|
||||||
package_base.PackageBase('test_format',
|
package_base.PackageBase('test_format',
|
||||||
'test_runtime_version',
|
'test_runtime_version',
|
||||||
@ -67,7 +67,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
full_names = ['.invalid_name_1', 'invalid..name..2', 'invalid name 3']
|
full_names = ['.invalid_name_1', 'invalid..name..2', 'invalid name 3']
|
||||||
for full_name in full_names:
|
for full_name in full_names:
|
||||||
expected_error_message = 'Invalid FullName {0}'.format(full_name)
|
expected_error_message = 'Invalid FullName {0}'.format(full_name)
|
||||||
with self.assertRaisesRegexp(exceptions.PackageFormatError,
|
with self.assertRaisesRegex(exceptions.PackageFormatError,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
package_base.PackageBase('test_format',
|
package_base.PackageBase('test_format',
|
||||||
'test_runtime_version',
|
'test_runtime_version',
|
||||||
@ -76,7 +76,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
|
|
||||||
def test_create_package_base_with_invalid_type(self):
|
def test_create_package_base_with_invalid_type(self):
|
||||||
package_type = 'Invalid'
|
package_type = 'Invalid'
|
||||||
with self.assertRaisesRegexp(exceptions.PackageFormatError,
|
with self.assertRaisesRegex(exceptions.PackageFormatError,
|
||||||
'Invalid package Type {0}'
|
'Invalid package Type {0}'
|
||||||
.format(package_type)):
|
.format(package_type)):
|
||||||
package_base.PackageBase('test_format',
|
package_base.PackageBase('test_format',
|
||||||
@ -86,19 +86,19 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
'Type': package_type})
|
'Type': package_type})
|
||||||
|
|
||||||
def test_requirements_negative(self):
|
def test_requirements_negative(self):
|
||||||
with self.assertRaisesRegexp(NotImplementedError, None):
|
with self.assertRaisesRegex(NotImplementedError, None):
|
||||||
self.package_base.requirements
|
self.package_base.requirements
|
||||||
|
|
||||||
def test_classes_negative(self):
|
def test_classes_negative(self):
|
||||||
with self.assertRaisesRegexp(NotImplementedError, None):
|
with self.assertRaisesRegex(NotImplementedError, None):
|
||||||
self.package_base.classes
|
self.package_base.classes
|
||||||
|
|
||||||
def test_get_class_negative(self):
|
def test_get_class_negative(self):
|
||||||
with self.assertRaisesRegexp(NotImplementedError, None):
|
with self.assertRaisesRegex(NotImplementedError, None):
|
||||||
self.package_base.get_class(None)
|
self.package_base.get_class(None)
|
||||||
|
|
||||||
def test_ui_negative(self):
|
def test_ui_negative(self):
|
||||||
with self.assertRaisesRegexp(NotImplementedError, None):
|
with self.assertRaisesRegex(NotImplementedError, None):
|
||||||
self.package_base.ui
|
self.package_base.ui
|
||||||
|
|
||||||
def test_full_name(self):
|
def test_full_name(self):
|
||||||
@ -144,7 +144,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
expected_error_message = 'Unable to load logo'
|
expected_error_message = 'Unable to load logo'
|
||||||
self.package_base._logo = ''.join(random.choice(string.ascii_letters)
|
self.package_base._logo = ''.join(random.choice(string.ascii_letters)
|
||||||
for _ in range(10))
|
for _ in range(10))
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self.package_base.logo
|
self.package_base.logo
|
||||||
self.package_base._logo = self.mock_manifest['Logo']
|
self.package_base._logo = self.mock_manifest['Logo']
|
||||||
@ -153,7 +153,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
what=mock.MagicMock(return_value='xyz'))
|
what=mock.MagicMock(return_value='xyz'))
|
||||||
def test_load_image_with_invalid_extension(self, mock_imghdr):
|
def test_load_image_with_invalid_extension(self, mock_imghdr):
|
||||||
expected_error_message = 'Unsupported Format.'
|
expected_error_message = 'Unsupported Format.'
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
|
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
|
||||||
full_path = os.path.join(self.package_base._source_directory,
|
full_path = os.path.join(self.package_base._source_directory,
|
||||||
@ -167,7 +167,7 @@ class TestPackageBase(test_base.MuranoTestCase):
|
|||||||
mock_os.stat.return_value = mock.MagicMock(st_size=5000 * 1024)
|
mock_os.stat.return_value = mock.MagicMock(st_size=5000 * 1024)
|
||||||
mock_os.isfile = mock.MagicMock(return_value=True)
|
mock_os.isfile = mock.MagicMock(return_value=True)
|
||||||
expected_error_message = 'Max allowed size is {0}'.format(500 * 1024)
|
expected_error_message = 'Max allowed size is {0}'.format(500 * 1024)
|
||||||
with self.assertRaisesRegexp(exceptions.PackageLoadError,
|
with self.assertRaisesRegex(exceptions.PackageLoadError,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
|
self.package_base._load_image('logo.xyz', 'logo.xyz', 'logo')
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class TestActions(test_base.MuranoTestCase):
|
|||||||
test_action_id = 'test_action_id'
|
test_action_id = 'test_action_id'
|
||||||
test_session = mock.MagicMock(description=[])
|
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,
|
actions.ActionServices.execute(test_action_id, test_session,
|
||||||
None, None, None)
|
None, None, None)
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class TestActions(test_base.MuranoTestCase):
|
|||||||
}]
|
}]
|
||||||
test_session = mock.MagicMock(description=test_description)
|
test_session = mock.MagicMock(description=test_description)
|
||||||
|
|
||||||
with self.assertRaisesRegexp(ValueError,
|
with self.assertRaisesRegex(ValueError,
|
||||||
'Cannot execute disabled action'):
|
'Cannot execute disabled action'):
|
||||||
actions.ActionServices.execute(test_action_id, test_session,
|
actions.ActionServices.execute(test_action_id, test_session,
|
||||||
None, None, None)
|
None, None, None)
|
||||||
|
@ -694,7 +694,7 @@ class TestHeatStack(base.MuranoTestCase):
|
|||||||
# Else EnvironmentError should be thrown.
|
# Else EnvironmentError should be thrown.
|
||||||
expected_error_msg = "Unexpected stack state {0}"\
|
expected_error_msg = "Unexpected stack state {0}"\
|
||||||
.format('NOT_FOUND')
|
.format('NOT_FOUND')
|
||||||
with self.assertRaisesRegexp(EnvironmentError,
|
with self.assertRaisesRegex(EnvironmentError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
||||||
|
|
||||||
@ -705,7 +705,7 @@ class TestHeatStack(base.MuranoTestCase):
|
|||||||
hs = heat_stack.HeatStack('test-stack', None)
|
hs = heat_stack.HeatStack('test-stack', None)
|
||||||
hs._client.stacks.get.side_effect = Exception('test_exception_msg')
|
hs._client.stacks.get.side_effect = Exception('test_exception_msg')
|
||||||
|
|
||||||
with self.assertRaisesRegexp(Exception,
|
with self.assertRaisesRegex(Exception,
|
||||||
'test_exception_msg'):
|
'test_exception_msg'):
|
||||||
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
||||||
|
|
||||||
@ -725,6 +725,6 @@ class TestHeatStack(base.MuranoTestCase):
|
|||||||
|
|
||||||
expected_error_msg = "Unexpected stack state {0}: {1}"\
|
expected_error_msg = "Unexpected stack state {0}: {1}"\
|
||||||
.format('UNEXPECTED_STATUS', 'test_reason')
|
.format('UNEXPECTED_STATUS', 'test_reason')
|
||||||
with self.assertRaisesRegexp(EnvironmentError,
|
with self.assertRaisesRegex(EnvironmentError,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
hs._wait_state(lambda status: status == 'CREATE_COMPLETE')
|
||||||
|
@ -45,7 +45,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
expected_error_message = 'Environment with id {env_id} not found'\
|
expected_error_message = 'Environment with id {env_id} not found'\
|
||||||
.format(env_id=test_env_id)
|
.format(env_id=test_env_id)
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPNotFound,
|
with self.assertRaisesRegex(exc.HTTPNotFound,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
utils.check_env(mock_request, test_env_id)
|
utils.check_env(mock_request, test_env_id)
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
expected_error_message = 'User is not authorized to access these '\
|
expected_error_message = 'User is not authorized to access these '\
|
||||||
'tenant resources'
|
'tenant resources'
|
||||||
|
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
utils.check_env(mock_request, mock_env.environment_id)
|
utils.check_env(mock_request, mock_env.environment_id)
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
"""Test check session with null session throws exception."""
|
"""Test check session with null session throws exception."""
|
||||||
expected_error_message = 'Session <SessionId {id}> is not found'\
|
expected_error_message = 'Session <SessionId {id}> is not found'\
|
||||||
.format(id=None)
|
.format(id=None)
|
||||||
with self.assertRaisesRegexp(exc.HTTPNotFound,
|
with self.assertRaisesRegex(exc.HTTPNotFound,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
utils.check_session(None, None, None, None)
|
utils.check_session(None, None, None, None)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
'with Environment <EnvId {environment_id}>'\
|
'with Environment <EnvId {environment_id}>'\
|
||||||
.format(session_id=mock_session.session_id,
|
.format(session_id=mock_session.session_id,
|
||||||
environment_id=environment_id)
|
environment_id=environment_id)
|
||||||
with self.assertRaisesRegexp(exc.HTTPBadRequest,
|
with self.assertRaisesRegex(exc.HTTPBadRequest,
|
||||||
expected_error_msg):
|
expected_error_msg):
|
||||||
utils.check_session(None, environment_id, mock_session,
|
utils.check_session(None, environment_id, mock_session,
|
||||||
mock_session.session_id)
|
mock_session.session_id)
|
||||||
@ -95,7 +95,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
mock_request = mock.MagicMock(context=dummy_context)
|
mock_request = mock.MagicMock(context=dummy_context)
|
||||||
expected_error_message = 'X-Configuration-Session header which '\
|
expected_error_message = 'X-Configuration-Session header which '\
|
||||||
'indicates to the session is missed'
|
'indicates to the session is missed'
|
||||||
with self.assertRaisesRegexp(exc.HTTPBadRequest,
|
with self.assertRaisesRegex(exc.HTTPBadRequest,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_session(mock_request)
|
self._test_verify_session(mock_request)
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
mock_db_session.get_session().query().get.return_value = None
|
mock_db_session.get_session().query().get.return_value = None
|
||||||
expected_error_message = 'Session <SessionId {0}> is not found'\
|
expected_error_message = 'Session <SessionId {0}> is not found'\
|
||||||
.format(mock_request.context.session)
|
.format(mock_request.context.session)
|
||||||
with self.assertRaisesRegexp(exc.HTTPNotFound,
|
with self.assertRaisesRegex(exc.HTTPNotFound,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_session(mock_request)
|
self._test_verify_session(mock_request)
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
mock_env_template
|
mock_env_template
|
||||||
expected_error_message = 'User is not authorized to access this'\
|
expected_error_message = 'User is not authorized to access this'\
|
||||||
' tenant resources'
|
' tenant resources'
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_env_template(mock_request, None)
|
self._test_verify_env_template(mock_request, None)
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
mock_db_session.get_session().query().get.return_value = None
|
mock_db_session.get_session().query().get.return_value = None
|
||||||
expected_error_message = 'Environment Template with id {id} not found'\
|
expected_error_message = 'Environment Template with id {id} not found'\
|
||||||
.format(id='test_env_template_id')
|
.format(id='test_env_template_id')
|
||||||
with self.assertRaisesRegexp(exc.HTTPNotFound,
|
with self.assertRaisesRegex(exc.HTTPNotFound,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_env_template(None, 'test_env_template_id')
|
self._test_verify_env_template(None, 'test_env_template_id')
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
'environment has been updated or '\
|
'environment has been updated or '\
|
||||||
'updating right now with other session'\
|
'updating right now with other session'\
|
||||||
.format(mock_request.context.session)
|
.format(mock_request.context.session)
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_session(mock_request)
|
self._test_verify_session(mock_request)
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class TestUtils(test_base.MuranoTestCase):
|
|||||||
expected_error_message = 'Session <SessionId {0}> is already in '\
|
expected_error_message = 'Session <SessionId {0}> is already in '\
|
||||||
'deployment state'\
|
'deployment state'\
|
||||||
.format(mock_request.context.session)
|
.format(mock_request.context.session)
|
||||||
with self.assertRaisesRegexp(exc.HTTPForbidden,
|
with self.assertRaisesRegex(exc.HTTPForbidden,
|
||||||
expected_error_message):
|
expected_error_message):
|
||||||
self._test_verify_session(mock_request)
|
self._test_verify_session(mock_request)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user