Fix 500 error on wrong definition
Closes-Bug: #1414921 Change-Id: I959e487006dee794ce74aa944291564a2c668b67
This commit is contained in:
parent
4d088ee033
commit
f636676b47
|
@ -158,6 +158,23 @@ workflows:
|
|||
"""
|
||||
|
||||
|
||||
INVALID_WF = """
|
||||
--
|
||||
version: 2.0
|
||||
|
||||
name: wb
|
||||
|
||||
workflows:
|
||||
wf1:
|
||||
type: direct
|
||||
|
||||
tasks:
|
||||
task1:
|
||||
action: std.echo output="Hey!"
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# TODO(rakhmerov): Add more tests when v2 spec is complete.
|
||||
# TODO(rakhmerov): Add negative tests.
|
||||
|
||||
|
@ -378,6 +395,14 @@ class DSLv2ModelTest(base.BaseTest):
|
|||
)
|
||||
self.assertIn("Wrong format of 'with-items'", str(exc))
|
||||
|
||||
def test_invalid_wf_spec(self):
|
||||
exc = self.assertRaises(
|
||||
exceptions.DSLParsingException,
|
||||
spec_parser.get_workflow_spec_from_yaml,
|
||||
INVALID_WF
|
||||
)
|
||||
self.assertIn("Definition could not be parsed", str(exc))
|
||||
|
||||
def test_to_dict(self):
|
||||
wb_spec = spec_parser.get_workbook_spec_from_yaml(VALID_WB)
|
||||
|
||||
|
|
|
@ -42,7 +42,9 @@ def parse_yaml(text):
|
|||
try:
|
||||
return yaml.safe_load(text)
|
||||
except error.YAMLError as e:
|
||||
raise RuntimeError("Definition could not be parsed: %s\n" % e)
|
||||
raise exc.DSLParsingException(
|
||||
"Definition could not be parsed: %s\n" % e
|
||||
)
|
||||
|
||||
|
||||
def _get_spec_version(spec_dict):
|
||||
|
|
Loading…
Reference in New Issue