Refactoring exception hierarchy
* Clear separation for problems that can be handled so that the program can continue and problems that can't handled automatically due to major issues in configuration, environment or code itself * Split YAQL exceptions into two types: grammar exception and evaluation exception * General NotFoundException is replaced with more specific DBEntryNotFoundException for better consistency with other DB exceptions and more clear semantics * Fixed corresponding tests Change-Id: I07f495ab316b0f164caece78b1f101219199e68c Implements: blueprint mistral-engine-error-handling
This commit is contained in:
parent
fa9f46b542
commit
96e6d7e403
@ -183,8 +183,9 @@ def get_workbook(name):
|
|||||||
wb = _get_workbook(name)
|
wb = _get_workbook(name)
|
||||||
|
|
||||||
if not wb:
|
if not wb:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Workbook not found [workbook_name=%s]" % name)
|
"Workbook not found [workbook_name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
return wb
|
return wb
|
||||||
|
|
||||||
@ -218,8 +219,9 @@ def update_workbook(name, values, session=None):
|
|||||||
wb = _get_workbook(name)
|
wb = _get_workbook(name)
|
||||||
|
|
||||||
if not wb:
|
if not wb:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Workbook not found [workbook_name=%s]" % name)
|
"Workbook not found [workbook_name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
wb.update(values.copy())
|
wb.update(values.copy())
|
||||||
|
|
||||||
@ -239,8 +241,9 @@ def delete_workbook(name, session=None):
|
|||||||
wb = _get_workbook(name)
|
wb = _get_workbook(name)
|
||||||
|
|
||||||
if not wb:
|
if not wb:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Workbook not found [workbook_name=%s]" % name)
|
"Workbook not found [workbook_name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
session.delete(wb)
|
session.delete(wb)
|
||||||
|
|
||||||
@ -281,7 +284,7 @@ def get_workflow_definition(identifier):
|
|||||||
else _get_workflow_definition(identifier))
|
else _get_workflow_definition(identifier))
|
||||||
|
|
||||||
if not wf_def:
|
if not wf_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Workflow not found [workflow_identifier=%s]" % identifier
|
"Workflow not found [workflow_identifier=%s]" % identifier
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -292,7 +295,7 @@ def get_workflow_definition_by_id(id):
|
|||||||
wf_def = _get_workflow_definition_by_id(id)
|
wf_def = _get_workflow_definition_by_id(id)
|
||||||
|
|
||||||
if not wf_def:
|
if not wf_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Workflow not found [workflow_id=%s]" % id
|
"Workflow not found [workflow_id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -363,7 +366,7 @@ def update_workflow_definition(identifier, values, session=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
[get_cron_trigger(name) for name in cron_triggers]
|
[get_cron_trigger(name) for name in cron_triggers]
|
||||||
except exc.NotFoundException:
|
except exc.DBEntityNotFoundException:
|
||||||
raise exc.NotAllowedException(
|
raise exc.NotAllowedException(
|
||||||
"Can not update scope of workflow that has triggers "
|
"Can not update scope of workflow that has triggers "
|
||||||
"associated in other tenants."
|
"associated in other tenants."
|
||||||
@ -446,7 +449,7 @@ def get_action_definition_by_id(id):
|
|||||||
action_def = _get_db_object_by_id(models.ActionDefinition, id)
|
action_def = _get_db_object_by_id(models.ActionDefinition, id)
|
||||||
|
|
||||||
if not action_def:
|
if not action_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Action not found [action_id=%s]" % id
|
"Action not found [action_id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -457,7 +460,7 @@ def get_action_definition(name):
|
|||||||
a_def = _get_action_definition(name)
|
a_def = _get_action_definition(name)
|
||||||
|
|
||||||
if not a_def:
|
if not a_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Action definition not found [action_name=%s]" % name
|
"Action definition not found [action_name=%s]" % name
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -509,8 +512,9 @@ def update_action_definition(name, values, session=None):
|
|||||||
a_def = _get_action_definition(name)
|
a_def = _get_action_definition(name)
|
||||||
|
|
||||||
if not a_def:
|
if not a_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Action definition not found [action_name=%s]" % name)
|
"Action definition not found [action_name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
a_def.update(values.copy())
|
a_def.update(values.copy())
|
||||||
|
|
||||||
@ -530,7 +534,7 @@ def delete_action_definition(name, session=None):
|
|||||||
a_def = _get_action_definition(name)
|
a_def = _get_action_definition(name)
|
||||||
|
|
||||||
if not a_def:
|
if not a_def:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Action definition not found [action_name=%s]" % name
|
"Action definition not found [action_name=%s]" % name
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -552,7 +556,7 @@ def get_execution(id):
|
|||||||
ex = _get_execution(id)
|
ex = _get_execution(id)
|
||||||
|
|
||||||
if not ex:
|
if not ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Execution not found [execution_id=%s]" % id
|
"Execution not found [execution_id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -592,7 +596,7 @@ def update_execution(id, values, session=None):
|
|||||||
ex = _get_execution(id)
|
ex = _get_execution(id)
|
||||||
|
|
||||||
if not ex:
|
if not ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Execution not found [execution_id=%s]" % id
|
"Execution not found [execution_id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -614,8 +618,9 @@ def delete_execution(id, session=None):
|
|||||||
ex = _get_execution(id)
|
ex = _get_execution(id)
|
||||||
|
|
||||||
if not ex:
|
if not ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Execution not found [execution_id=%s]" % id)
|
"Execution not found [execution_id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
session.delete(ex)
|
session.delete(ex)
|
||||||
|
|
||||||
@ -639,8 +644,9 @@ def get_action_execution(id):
|
|||||||
a_ex = _get_action_execution(id)
|
a_ex = _get_action_execution(id)
|
||||||
|
|
||||||
if not a_ex:
|
if not a_ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"ActionExecution not found [id=%s]" % id)
|
"ActionExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
return a_ex
|
return a_ex
|
||||||
|
|
||||||
@ -678,7 +684,7 @@ def update_action_execution(id, values, session=None):
|
|||||||
a_ex = _get_action_execution(id)
|
a_ex = _get_action_execution(id)
|
||||||
|
|
||||||
if not a_ex:
|
if not a_ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"ActionExecution not found [id=%s]" % id
|
"ActionExecution not found [id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -700,7 +706,7 @@ def delete_action_execution(id, session=None):
|
|||||||
a_ex = _get_action_execution(id)
|
a_ex = _get_action_execution(id)
|
||||||
|
|
||||||
if not a_ex:
|
if not a_ex:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"ActionExecution not found [id=%s]" % id
|
"ActionExecution not found [id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -726,7 +732,9 @@ def get_workflow_execution(id):
|
|||||||
wf_ex = _get_workflow_execution(id)
|
wf_ex = _get_workflow_execution(id)
|
||||||
|
|
||||||
if not wf_ex:
|
if not wf_ex:
|
||||||
raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"WorkflowExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
return wf_ex
|
return wf_ex
|
||||||
|
|
||||||
@ -780,7 +788,9 @@ def update_workflow_execution(id, values, session=None):
|
|||||||
wf_ex = _get_workflow_execution(id)
|
wf_ex = _get_workflow_execution(id)
|
||||||
|
|
||||||
if not wf_ex:
|
if not wf_ex:
|
||||||
raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"WorkflowExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
wf_ex.update(values.copy())
|
wf_ex.update(values.copy())
|
||||||
|
|
||||||
@ -800,7 +810,9 @@ def delete_workflow_execution(id, session=None):
|
|||||||
wf_ex = _get_workflow_execution(id)
|
wf_ex = _get_workflow_execution(id)
|
||||||
|
|
||||||
if not wf_ex:
|
if not wf_ex:
|
||||||
raise exc.NotFoundException("WorkflowExecution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"WorkflowExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
session.delete(wf_ex)
|
session.delete(wf_ex)
|
||||||
|
|
||||||
@ -820,7 +832,9 @@ def get_task_execution(id):
|
|||||||
task_ex = _get_task_execution(id)
|
task_ex = _get_task_execution(id)
|
||||||
|
|
||||||
if not task_ex:
|
if not task_ex:
|
||||||
raise exc.NotFoundException("Task execution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Task execution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
return task_ex
|
return task_ex
|
||||||
|
|
||||||
@ -854,7 +868,9 @@ def update_task_execution(id, values, session=None):
|
|||||||
task_ex = _get_task_execution(id)
|
task_ex = _get_task_execution(id)
|
||||||
|
|
||||||
if not task_ex:
|
if not task_ex:
|
||||||
raise exc.NotFoundException("TaskExecution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"TaskExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
task_ex.update(values.copy())
|
task_ex.update(values.copy())
|
||||||
|
|
||||||
@ -874,7 +890,9 @@ def delete_task_execution(id, session=None):
|
|||||||
task_ex = _get_task_execution(id)
|
task_ex = _get_task_execution(id)
|
||||||
|
|
||||||
if not task_ex:
|
if not task_ex:
|
||||||
raise exc.NotFoundException("TaskExecution not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"TaskExecution not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
session.delete(task_ex)
|
session.delete(task_ex)
|
||||||
|
|
||||||
@ -914,7 +932,7 @@ def delete_delayed_call(id, session=None):
|
|||||||
delayed_call = _get_delayed_call(id)
|
delayed_call = _get_delayed_call(id)
|
||||||
|
|
||||||
if not delayed_call:
|
if not delayed_call:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"DelayedCall not found [id=%s]" % id
|
"DelayedCall not found [id=%s]" % id
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -964,7 +982,9 @@ def get_delayed_call(id, session=None):
|
|||||||
delayed_call = _get_delayed_call(id=id, session=session)
|
delayed_call = _get_delayed_call(id=id, session=session)
|
||||||
|
|
||||||
if not delayed_call:
|
if not delayed_call:
|
||||||
raise exc.NotFoundException("Delayed Call not found [id=%s]" % id)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Delayed Call not found [id=%s]" % id
|
||||||
|
)
|
||||||
|
|
||||||
return delayed_call
|
return delayed_call
|
||||||
|
|
||||||
@ -1000,8 +1020,9 @@ def get_cron_trigger(name):
|
|||||||
cron_trigger = _get_cron_trigger(name)
|
cron_trigger = _get_cron_trigger(name)
|
||||||
|
|
||||||
if not cron_trigger:
|
if not cron_trigger:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Cron trigger not found [name=%s]" % name)
|
"Cron trigger not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
return cron_trigger
|
return cron_trigger
|
||||||
|
|
||||||
@ -1052,7 +1073,9 @@ def update_cron_trigger(name, values, session=None, query_filter=None):
|
|||||||
cron_trigger = _get_cron_trigger(name)
|
cron_trigger = _get_cron_trigger(name)
|
||||||
|
|
||||||
if not cron_trigger:
|
if not cron_trigger:
|
||||||
raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Cron trigger not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
if query_filter:
|
if query_filter:
|
||||||
try:
|
try:
|
||||||
@ -1099,7 +1122,9 @@ def delete_cron_trigger(name, session=None):
|
|||||||
cron_trigger = _get_cron_trigger(name)
|
cron_trigger = _get_cron_trigger(name)
|
||||||
|
|
||||||
if not cron_trigger:
|
if not cron_trigger:
|
||||||
raise exc.NotFoundException("Cron trigger not found [name=%s]" % name)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Cron trigger not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
# Delete the cron trigger by ID and get the affected row count.
|
# Delete the cron trigger by ID and get the affected row count.
|
||||||
table = models.CronTrigger.__table__
|
table = models.CronTrigger.__table__
|
||||||
@ -1131,7 +1156,9 @@ def get_environment(name):
|
|||||||
env = _get_environment(name)
|
env = _get_environment(name)
|
||||||
|
|
||||||
if not env:
|
if not env:
|
||||||
raise exc.NotFoundException("Environment not found [name=%s]" % name)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Environment not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
@ -1165,7 +1192,9 @@ def update_environment(name, values, session=None):
|
|||||||
env = _get_environment(name)
|
env = _get_environment(name)
|
||||||
|
|
||||||
if not env:
|
if not env:
|
||||||
raise exc.NotFoundException("Environment not found [name=%s]" % name)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Environment not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
env.update(values)
|
env.update(values)
|
||||||
|
|
||||||
@ -1187,7 +1216,9 @@ def delete_environment(name, session=None):
|
|||||||
env = _get_environment(name)
|
env = _get_environment(name)
|
||||||
|
|
||||||
if not env:
|
if not env:
|
||||||
raise exc.NotFoundException("Environment not found [name=%s]" % name)
|
raise exc.DBEntityNotFoundException(
|
||||||
|
"Environment not found [name=%s]" % name
|
||||||
|
)
|
||||||
|
|
||||||
session.delete(env)
|
session.delete(env)
|
||||||
|
|
||||||
@ -1268,7 +1299,7 @@ def get_resource_member(resource_id, res_type, member_id):
|
|||||||
).first()
|
).first()
|
||||||
|
|
||||||
if not res_member:
|
if not res_member:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Resource member not found [resource_id=%s, member_id=%s]" %
|
"Resource member not found [resource_id=%s, member_id=%s]" %
|
||||||
(resource_id, member_id)
|
(resource_id, member_id)
|
||||||
)
|
)
|
||||||
@ -1298,7 +1329,7 @@ def update_resource_member(resource_id, res_type, member_id, values,
|
|||||||
# Only member who is not the owner of the resource can update the
|
# Only member who is not the owner of the resource can update the
|
||||||
# membership status.
|
# membership status.
|
||||||
if member_id != security.get_project_id():
|
if member_id != security.get_project_id():
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Resource member not found [resource_id=%s, member_id=%s]" %
|
"Resource member not found [resource_id=%s, member_id=%s]" %
|
||||||
(resource_id, member_id)
|
(resource_id, member_id)
|
||||||
)
|
)
|
||||||
@ -1312,7 +1343,7 @@ def update_resource_member(resource_id, res_type, member_id, values,
|
|||||||
).first()
|
).first()
|
||||||
|
|
||||||
if not res_member:
|
if not res_member:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Resource member not found [resource_id=%s, member_id=%s]" %
|
"Resource member not found [resource_id=%s, member_id=%s]" %
|
||||||
(resource_id, member_id)
|
(resource_id, member_id)
|
||||||
)
|
)
|
||||||
@ -1331,7 +1362,7 @@ def delete_resource_member(resource_id, res_type, member_id, session=None):
|
|||||||
res_member = query.filter(_get_criterion(resource_id, member_id)).first()
|
res_member = query.filter(_get_criterion(resource_id, member_id)).first()
|
||||||
|
|
||||||
if not res_member:
|
if not res_member:
|
||||||
raise exc.NotFoundException(
|
raise exc.DBEntityNotFoundException(
|
||||||
"Resource member not found [resource_id=%s, member_id=%s]" %
|
"Resource member not found [resource_id=%s, member_id=%s]" %
|
||||||
(resource_id, member_id)
|
(resource_id, member_id)
|
||||||
)
|
)
|
||||||
|
@ -14,16 +14,34 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class MistralError(Exception):
|
||||||
|
"""Mistral specific error.
|
||||||
|
|
||||||
|
Reserved for situations that can't automatically handled. When it occurs
|
||||||
|
it signals that there is a major environmental problem like invalid startup
|
||||||
|
configuration or implementation problem (e.g. some code doesn't take care
|
||||||
|
of certain corner cases). From architectural perspective it's pointless to
|
||||||
|
try to handle this type of problems except doing some finalization work
|
||||||
|
like transaction rollback, deleting temporary files etc.
|
||||||
|
"""
|
||||||
def __init__(self, message=None):
|
def __init__(self, message=None):
|
||||||
super(Error, self).__init__(message)
|
super(MistralError, self).__init__(message)
|
||||||
|
|
||||||
|
|
||||||
class MistralException(Error):
|
class MistralException(Exception):
|
||||||
"""Base Exception for the project
|
"""Mistral specific exception.
|
||||||
|
|
||||||
To correctly use this class, inherit from it and define
|
Reserved for situations that are not critical for program continuation.
|
||||||
a 'message' and 'http_code' properties.
|
It is possible to recover from this type of problems automatically and
|
||||||
|
continue program execution. Such problems may be related with invalid user
|
||||||
|
input (such as invalid syntax) or temporary environmental problems.
|
||||||
|
|
||||||
|
In case if an instance of a certain exception type bubbles up to API layer
|
||||||
|
then this type of exception it must be associated with an http code so it's
|
||||||
|
clear how to represent it for a client.
|
||||||
|
|
||||||
|
To correctly use this class, inherit from it and define a 'message' and
|
||||||
|
'http_code' properties.
|
||||||
"""
|
"""
|
||||||
message = "An unknown exception occurred"
|
message = "An unknown exception occurred"
|
||||||
http_code = 500
|
http_code = 500
|
||||||
@ -42,29 +60,55 @@ class MistralException(Error):
|
|||||||
def __init__(self, message=None):
|
def __init__(self, message=None):
|
||||||
if message is not None:
|
if message is not None:
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
super(MistralException, self).__init__(
|
super(MistralException, self).__init__(
|
||||||
'%d: %s' % (self.http_code, self.message))
|
'%d: %s' % (self.http_code, self.message))
|
||||||
|
|
||||||
|
|
||||||
|
# Database exceptions.
|
||||||
|
|
||||||
class DBException(MistralException):
|
class DBException(MistralException):
|
||||||
http_code = 400
|
http_code = 400
|
||||||
|
|
||||||
|
|
||||||
class DataAccessException(MistralException):
|
class DBDuplicateEntryException(DBException):
|
||||||
http_code = 400
|
|
||||||
|
|
||||||
|
|
||||||
class NotFoundException(MistralException):
|
|
||||||
http_code = 404
|
|
||||||
message = "Object not found"
|
|
||||||
|
|
||||||
|
|
||||||
class DBDuplicateEntryException(MistralException):
|
|
||||||
http_code = 409
|
http_code = 409
|
||||||
message = "Database object already exists"
|
message = "Database object already exists"
|
||||||
|
|
||||||
|
|
||||||
class DBQueryEntryException(MistralException):
|
class DBQueryEntryException(DBException):
|
||||||
|
http_code = 400
|
||||||
|
|
||||||
|
|
||||||
|
class DBEntityNotFoundException(DBException):
|
||||||
|
http_code = 404
|
||||||
|
message = "Object not found"
|
||||||
|
|
||||||
|
|
||||||
|
# DSL exceptions.
|
||||||
|
|
||||||
|
class DSLParsingException(MistralException):
|
||||||
|
http_code = 400
|
||||||
|
|
||||||
|
|
||||||
|
class YaqlGrammarException(DSLParsingException):
|
||||||
|
http_code = 400
|
||||||
|
message = "Invalid grammar of YAQL expression"
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidModelException(DSLParsingException):
|
||||||
|
http_code = 400
|
||||||
|
message = "Wrong entity definition"
|
||||||
|
|
||||||
|
|
||||||
|
# Various common exceptions.
|
||||||
|
|
||||||
|
class YaqlEvaluationException(MistralException):
|
||||||
|
http_code = 400
|
||||||
|
message = "Can not evaluate YAQL expression"
|
||||||
|
|
||||||
|
|
||||||
|
class DataAccessException(MistralException):
|
||||||
http_code = 400
|
http_code = 400
|
||||||
|
|
||||||
|
|
||||||
@ -97,20 +141,6 @@ class ApplicationContextNotFoundException(MistralException):
|
|||||||
message = "Application context not found"
|
message = "Application context not found"
|
||||||
|
|
||||||
|
|
||||||
class DSLParsingException(MistralException):
|
|
||||||
http_code = 400
|
|
||||||
|
|
||||||
|
|
||||||
class YaqlEvaluationException(DSLParsingException):
|
|
||||||
http_code = 400
|
|
||||||
message = "Can not evaluate YAQL expression"
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidModelException(DSLParsingException):
|
|
||||||
http_code = 400
|
|
||||||
message = "Wrong entity definition"
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidResultException(MistralException):
|
class InvalidResultException(MistralException):
|
||||||
http_code = 400
|
http_code = 400
|
||||||
message = "Unable to parse result"
|
message = "Unable to parse result"
|
||||||
|
@ -78,7 +78,7 @@ class YAQLEvaluator(Evaluator):
|
|||||||
try:
|
try:
|
||||||
YAQL_ENGINE(expression)
|
YAQL_ENGINE(expression)
|
||||||
except (yaql_exc.YaqlException, KeyError, ValueError, TypeError) as e:
|
except (yaql_exc.YaqlException, KeyError, ValueError, TypeError) as e:
|
||||||
raise exc.YaqlEvaluationException(getattr(e, 'message', e))
|
raise exc.YaqlGrammarException(getattr(e, 'message', e))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def evaluate(cls, expression, data_context):
|
def evaluate(cls, expression, data_context):
|
||||||
|
@ -108,7 +108,7 @@ def advance_cron_trigger(t):
|
|||||||
'next_execution_time': t.next_execution_time
|
'next_execution_time': t.next_execution_time
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except exc.NotFoundException as e:
|
except exc.DBEntityNotFoundException as e:
|
||||||
# Cron trigger was probably already deleted by a different process.
|
# Cron trigger was probably already deleted by a different process.
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Cron trigger named '%s' does not exist anymore: %s",
|
"Cron trigger named '%s' does not exist anymore: %s",
|
||||||
|
@ -116,7 +116,7 @@ MOCK_ACTION_NOT_COMPLETE = mock.MagicMock(
|
|||||||
MOCK_AD_HOC_ACTION = mock.MagicMock(return_value=AD_HOC_ACTION_EX_DB)
|
MOCK_AD_HOC_ACTION = mock.MagicMock(return_value=AD_HOC_ACTION_EX_DB)
|
||||||
MOCK_ACTIONS = mock.MagicMock(return_value=[ACTION_EX_DB])
|
MOCK_ACTIONS = mock.MagicMock(return_value=[ACTION_EX_DB])
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ MOCK_ACTIONS = mock.MagicMock(return_value=[ACTION_DB])
|
|||||||
MOCK_UPDATED_ACTION = mock.MagicMock(return_value=UPDATED_ACTION_DB)
|
MOCK_UPDATED_ACTION = mock.MagicMock(return_value=UPDATED_ACTION_DB)
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ MOCK_TRIGGER = mock.MagicMock(return_value=TRIGGER_DB)
|
|||||||
MOCK_TRIGGERS = mock.MagicMock(return_value=[TRIGGER_DB])
|
MOCK_TRIGGERS = mock.MagicMock(return_value=[TRIGGER_DB])
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ MOCK_ENVIRONMENT = mock.MagicMock(return_value=ENVIRONMENT_DB)
|
|||||||
MOCK_ENVIRONMENTS = mock.MagicMock(return_value=[ENVIRONMENT_DB])
|
MOCK_ENVIRONMENTS = mock.MagicMock(return_value=[ENVIRONMENT_DB])
|
||||||
MOCK_UPDATED_ENVIRONMENT = mock.MagicMock(return_value=UPDATED_ENVIRONMENT_DB)
|
MOCK_UPDATED_ENVIRONMENT = mock.MagicMock(return_value=UPDATED_ENVIRONMENT_DB)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ MOCK_WF_EXECUTIONS = mock.MagicMock(return_value=[WF_EX])
|
|||||||
MOCK_UPDATED_WF_EX = mock.MagicMock(return_value=UPDATED_WF_EX)
|
MOCK_UPDATED_WF_EX = mock.MagicMock(return_value=UPDATED_WF_EX)
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_ACTION_EXC = mock.MagicMock(side_effect=exc.ActionException())
|
MOCK_ACTION_EXC = mock.MagicMock(side_effect=exc.ActionException())
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ MOCK_WF_EX = mock.MagicMock(return_value=WF_EX)
|
|||||||
MOCK_TASK = mock.MagicMock(return_value=TASK_EX)
|
MOCK_TASK = mock.MagicMock(return_value=TASK_EX)
|
||||||
MOCK_TASKS = mock.MagicMock(return_value=[TASK_EX])
|
MOCK_TASKS = mock.MagicMock(return_value=[TASK_EX])
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_ERROR_TASK = mock.MagicMock(return_value=ERROR_TASK_EX)
|
MOCK_ERROR_TASK = mock.MagicMock(return_value=ERROR_TASK_EX)
|
||||||
MOCK_ERROR_ITEMS_TASK = mock.MagicMock(return_value=ERROR_ITEMS_TASK_EX)
|
MOCK_ERROR_ITEMS_TASK = mock.MagicMock(return_value=ERROR_ITEMS_TASK_EX)
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ MOCK_WORKBOOKS = mock.MagicMock(return_value=[WORKBOOK_DB])
|
|||||||
MOCK_UPDATED_WORKBOOK = mock.MagicMock(return_value=UPDATED_WORKBOOK_DB)
|
MOCK_UPDATED_WORKBOOK = mock.MagicMock(return_value=UPDATED_WORKBOOK_DB)
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ MOCK_WFS = mock.MagicMock(return_value=[WF_DB])
|
|||||||
MOCK_UPDATED_WF = mock.MagicMock(return_value=UPDATED_WF_DB)
|
MOCK_UPDATED_WF = mock.MagicMock(return_value=UPDATED_WF_DB)
|
||||||
MOCK_DELETE = mock.MagicMock(return_value=None)
|
MOCK_DELETE = mock.MagicMock(return_value=None)
|
||||||
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
MOCK_EMPTY = mock.MagicMock(return_value=[])
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ class WorkbookTest(SQLAlchemyTest):
|
|||||||
db_api.delete_workbook(created.name)
|
db_api.delete_workbook(created.name)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workbook,
|
db_api.get_workbook,
|
||||||
created.name
|
created.name
|
||||||
)
|
)
|
||||||
@ -424,7 +424,7 @@ class WorkflowDefinitionTest(SQLAlchemyTest):
|
|||||||
db_api.delete_workflow_definition(identifier)
|
db_api.delete_workflow_definition(identifier)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workflow_definition,
|
db_api.get_workflow_definition,
|
||||||
identifier
|
identifier
|
||||||
)
|
)
|
||||||
@ -606,7 +606,7 @@ class ActionDefinitionTest(SQLAlchemyTest):
|
|||||||
db_api.delete_action_definition(created.name)
|
db_api.delete_action_definition(created.name)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_action_definition,
|
db_api.get_action_definition,
|
||||||
created.name
|
created.name
|
||||||
)
|
)
|
||||||
@ -726,7 +726,7 @@ class ActionExecutionTest(SQLAlchemyTest):
|
|||||||
db_api.delete_action_execution(created.id)
|
db_api.delete_action_execution(created.id)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_action_execution,
|
db_api.get_action_execution,
|
||||||
created.id
|
created.id
|
||||||
)
|
)
|
||||||
@ -738,7 +738,7 @@ class ActionExecutionTest(SQLAlchemyTest):
|
|||||||
auth_context.set_ctx(test_base.get_context(default=False))
|
auth_context.set_ctx(test_base.get_context(default=False))
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.delete_action_execution,
|
db_api.delete_action_execution,
|
||||||
created.id
|
created.id
|
||||||
)
|
)
|
||||||
@ -880,7 +880,7 @@ class WorkflowExecutionTest(SQLAlchemyTest):
|
|||||||
db_api.delete_workflow_execution(created.id)
|
db_api.delete_workflow_execution(created.id)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workflow_execution,
|
db_api.get_workflow_execution,
|
||||||
created.id
|
created.id
|
||||||
)
|
)
|
||||||
@ -1130,7 +1130,7 @@ class TaskExecutionTest(SQLAlchemyTest):
|
|||||||
db_api.delete_task_execution(created.id)
|
db_api.delete_task_execution(created.id)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_task_execution,
|
db_api.get_task_execution,
|
||||||
created.id
|
created.id
|
||||||
)
|
)
|
||||||
@ -1302,7 +1302,7 @@ class CronTriggerTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
self.assertEqual(1, rowcount)
|
self.assertEqual(1, rowcount)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_cron_trigger,
|
db_api.get_cron_trigger,
|
||||||
created.name
|
created.name
|
||||||
)
|
)
|
||||||
@ -1432,7 +1432,7 @@ class EnvironmentTest(SQLAlchemyTest):
|
|||||||
db_api.delete_environment(created.name)
|
db_api.delete_environment(created.name)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_environment,
|
db_api.get_environment,
|
||||||
created.name
|
created.name
|
||||||
)
|
)
|
||||||
@ -1462,7 +1462,7 @@ class TXTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
self.assertFalse(self.is_db_session_open())
|
self.assertFalse(self.is_db_session_open())
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workbook,
|
db_api.get_workbook,
|
||||||
created['id']
|
created['id']
|
||||||
)
|
)
|
||||||
@ -1525,12 +1525,12 @@ class TXTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
self.assertFalse(self.is_db_session_open())
|
self.assertFalse(self.is_db_session_open())
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workflow_execution,
|
db_api.get_workflow_execution,
|
||||||
created.id
|
created.id
|
||||||
)
|
)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workbook,
|
db_api.get_workbook,
|
||||||
created_wb.name
|
created_wb.name
|
||||||
)
|
)
|
||||||
@ -1553,7 +1553,7 @@ class TXTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
self.assertFalse(self.is_db_session_open())
|
self.assertFalse(self.is_db_session_open())
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workbook,
|
db_api.get_workbook,
|
||||||
created.name
|
created.name
|
||||||
)
|
)
|
||||||
@ -1633,7 +1633,7 @@ class ResourceMemberTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
# Tenant A can not see membership of resource shared to Tenant B.
|
# Tenant A can not see membership of resource shared to Tenant B.
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_resource_member,
|
db_api.get_resource_member,
|
||||||
'123e4567-e89b-12d3-a456-426655440000',
|
'123e4567-e89b-12d3-a456-426655440000',
|
||||||
'workflow',
|
'workflow',
|
||||||
@ -1695,7 +1695,7 @@ class ResourceMemberTest(SQLAlchemyTest):
|
|||||||
created = db_api.create_resource_member(RESOURCE_MEMBERS[0])
|
created = db_api.create_resource_member(RESOURCE_MEMBERS[0])
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.update_resource_member,
|
db_api.update_resource_member,
|
||||||
created.resource_id,
|
created.resource_id,
|
||||||
'workflow',
|
'workflow',
|
||||||
@ -1726,7 +1726,7 @@ class ResourceMemberTest(SQLAlchemyTest):
|
|||||||
auth_context.set_ctx(user_context)
|
auth_context.set_ctx(user_context)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.delete_resource_member,
|
db_api.delete_resource_member,
|
||||||
created.resource_id,
|
created.resource_id,
|
||||||
'workflow',
|
'workflow',
|
||||||
@ -1743,7 +1743,7 @@ class ResourceMemberTest(SQLAlchemyTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.delete_resource_member,
|
db_api.delete_resource_member,
|
||||||
created.resource_id,
|
created.resource_id,
|
||||||
'workflow',
|
'workflow',
|
||||||
@ -1752,7 +1752,7 @@ class ResourceMemberTest(SQLAlchemyTest):
|
|||||||
|
|
||||||
def test_delete_nonexistent_resource_member(self):
|
def test_delete_nonexistent_resource_member(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.delete_resource_member,
|
db_api.delete_resource_member,
|
||||||
'nonexitent_resource',
|
'nonexitent_resource',
|
||||||
'workflow',
|
'workflow',
|
||||||
@ -1768,7 +1768,7 @@ class WorkflowSharingTest(SQLAlchemyTest):
|
|||||||
auth_context.set_ctx(user_context)
|
auth_context.set_ctx(user_context)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workflow_definition,
|
db_api.get_workflow_definition,
|
||||||
wf.id
|
wf.id
|
||||||
)
|
)
|
||||||
@ -1836,7 +1836,7 @@ class WorkflowSharingTest(SQLAlchemyTest):
|
|||||||
auth_context.set_ctx(user_context)
|
auth_context.set_ctx(user_context)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
db_api.get_workflow_definition,
|
db_api.get_workflow_definition,
|
||||||
wf.id
|
wf.id
|
||||||
)
|
)
|
||||||
|
@ -89,7 +89,7 @@ ENVIRONMENT_DB = models.Environment(
|
|||||||
)
|
)
|
||||||
|
|
||||||
MOCK_ENVIRONMENT = mock.MagicMock(return_value=ENVIRONMENT_DB)
|
MOCK_ENVIRONMENT = mock.MagicMock(return_value=ENVIRONMENT_DB)
|
||||||
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
|
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.DBEntityNotFoundException())
|
||||||
|
|
||||||
|
|
||||||
class DefaultEngineTest(base.DbTestCase):
|
class DefaultEngineTest(base.DbTestCase):
|
||||||
@ -233,7 +233,7 @@ class DefaultEngineTest(base.DbTestCase):
|
|||||||
|
|
||||||
@mock.patch.object(db_api, "get_environment", MOCK_NOT_FOUND)
|
@mock.patch.object(db_api, "get_environment", MOCK_NOT_FOUND)
|
||||||
def test_start_workflow_env_not_found(self):
|
def test_start_workflow_env_not_found(self):
|
||||||
self.assertRaises(exc.NotFoundException,
|
self.assertRaises(exc.DBEntityNotFoundException,
|
||||||
self.engine.start_workflow,
|
self.engine.start_workflow,
|
||||||
'wb.wf',
|
'wb.wf',
|
||||||
{'param1': '<% env().key1 %>'},
|
{'param1': '<% env().key1 %>'},
|
||||||
|
@ -289,7 +289,7 @@ class SchedulerServiceTest(base.DbTestCase):
|
|||||||
|
|
||||||
eventlet.sleep(WAIT)
|
eventlet.sleep(WAIT)
|
||||||
|
|
||||||
self.assertRaises(exc.NotFoundException,
|
self.assertRaises(exc.DBEntityNotFoundException,
|
||||||
db_api.get_delayed_call,
|
db_api.get_delayed_call,
|
||||||
calls[0].id
|
calls[0].id
|
||||||
)
|
)
|
||||||
@ -336,7 +336,7 @@ class SchedulerServiceTest(base.DbTestCase):
|
|||||||
eventlet.sleep(WAIT)
|
eventlet.sleep(WAIT)
|
||||||
|
|
||||||
# If the scheduler does handel calls that failed on update
|
# If the scheduler does handel calls that failed on update
|
||||||
# NotFoundException will raise.
|
# DBEntityNotFoundException will raise.
|
||||||
db_api.get_delayed_call(calls[0].id)
|
db_api.get_delayed_call(calls[0].id)
|
||||||
|
|
||||||
db_api.delete_delayed_call(calls[0].id)
|
db_api.delete_delayed_call(calls[0].id)
|
||||||
|
@ -165,7 +165,7 @@ class WorkflowServiceTest(base.DbTestCase):
|
|||||||
|
|
||||||
def test_update_non_existing_workflow_failed(self):
|
def test_update_non_existing_workflow_failed(self):
|
||||||
exception = self.assertRaises(
|
exception = self.assertRaises(
|
||||||
exc.NotFoundException,
|
exc.DBEntityNotFoundException,
|
||||||
wf_service.update_workflows,
|
wf_service.update_workflows,
|
||||||
WORKFLOW
|
WORKFLOW
|
||||||
)
|
)
|
||||||
|
@ -24,13 +24,13 @@ class ExceptionTestCase(base.BaseTest):
|
|||||||
"""Test cases for exception code."""
|
"""Test cases for exception code."""
|
||||||
|
|
||||||
def test_nf_with_message(self):
|
def test_nf_with_message(self):
|
||||||
exc = exceptions.NotFoundException('check_for_this')
|
exc = exceptions.DBEntityNotFoundException('check_for_this')
|
||||||
self.assertIn('check_for_this',
|
self.assertIn('check_for_this',
|
||||||
six.text_type(exc))
|
six.text_type(exc))
|
||||||
self.assertEqual(404, exc.http_code)
|
self.assertEqual(404, exc.http_code)
|
||||||
|
|
||||||
def test_nf_with_no_message(self):
|
def test_nf_with_no_message(self):
|
||||||
exc = exceptions.NotFoundException()
|
exc = exceptions.DBEntityNotFoundException()
|
||||||
self.assertIn("Object not found",
|
self.assertIn("Object not found",
|
||||||
six.text_type(exc))
|
six.text_type(exc))
|
||||||
self.assertEqual(404, exc.http_code,)
|
self.assertEqual(404, exc.http_code,)
|
||||||
|
@ -99,15 +99,15 @@ class YaqlEvaluatorTest(base.BaseTest):
|
|||||||
self._evaluator.validate('$.a1 * $.a2')
|
self._evaluator.validate('$.a1 * $.a2')
|
||||||
|
|
||||||
def test_validate_failed(self):
|
def test_validate_failed(self):
|
||||||
self.assertRaises(exc.YaqlEvaluationException,
|
self.assertRaises(exc.YaqlGrammarException,
|
||||||
self._evaluator.validate,
|
self._evaluator.validate,
|
||||||
'*')
|
'*')
|
||||||
|
|
||||||
self.assertRaises(exc.YaqlEvaluationException,
|
self.assertRaises(exc.YaqlGrammarException,
|
||||||
self._evaluator.validate,
|
self._evaluator.validate,
|
||||||
[1, 2, 3])
|
[1, 2, 3])
|
||||||
|
|
||||||
self.assertRaises(exc.YaqlEvaluationException,
|
self.assertRaises(exc.YaqlGrammarException,
|
||||||
self._evaluator.validate,
|
self._evaluator.validate,
|
||||||
{'a': 1})
|
{'a': 1})
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class InlineYAQLEvaluatorTest(base.BaseTest):
|
|||||||
self._evaluator.validate('The value is <% $.a1 %>.')
|
self._evaluator.validate('The value is <% $.a1 %>.')
|
||||||
|
|
||||||
def test_validate_failed(self):
|
def test_validate_failed(self):
|
||||||
self.assertRaises(exc.YaqlEvaluationException,
|
self.assertRaises(exc.YaqlGrammarException,
|
||||||
self._evaluator.validate,
|
self._evaluator.validate,
|
||||||
'The value is <% * %>.')
|
'The value is <% * %>.')
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ def get_controller(wf_ex, wf_spec=None):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not ctrl_cls:
|
if not ctrl_cls:
|
||||||
raise exc.NotFoundException(
|
raise exc.MistralError(
|
||||||
'Failed to find a workflow controller [type=%s]' % wf_type
|
'Failed to find a workflow controller [type=%s]' % wf_type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user