diff --git a/mistral/lang/v2/tasks.py b/mistral/lang/v2/tasks.py index 065a70d8..9c7cc68f 100644 --- a/mistral/lang/v2/tasks.py +++ b/mistral/lang/v2/tasks.py @@ -128,6 +128,7 @@ class TaskSpec(base.BaseSpec): self.validate_expr(self._data.get('input', {})) self.validate_expr(self._data.get('publish', {})) + self.validate_expr(self._data.get('publish-on-error', {})) self.validate_expr(self._data.get('keep-result', {})) self.validate_expr(self._data.get('safe-rerun', {})) diff --git a/mistral/tests/unit/lang/v2/test_tasks.py b/mistral/tests/unit/lang/v2/test_tasks.py index b2b010c5..e6b08f20 100644 --- a/mistral/tests/unit/lang/v2/test_tasks.py +++ b/mistral/tests/unit/lang/v2/test_tasks.py @@ -166,6 +166,31 @@ class TaskSpecValidation(v2_base.WorkflowSpecValidationTestCase): expect_error=expect_error ) + def test_publish_on_error(self): + tests = [ + ({'publish-on-error': ''}, True), + ({'publish-on-error': {}}, True), + ({'publish-on-error': None}, True), + ({'publish-on-error': {'k1': 'v1'}}, False), + ({'publish-on-error': {'k1': '<% $.v1 %>'}}, False), + ({'publish-on-error': {'k1': '<% 1 + 2 %>'}}, False), + ({'publish-on-error': {'k1': '<% * %>'}}, True), + ({'publish-on-error': {'k1': '{{ _.v1 }}'}}, False), + ({'publish-on-error': {'k1': '{{ 1 + 2 }}'}}, False), + ({'publish-on-error': {'k1': '{{ * }}'}}, True) + ] + + for output, expect_error in tests: + overlay = {'test': {'tasks': {'task1': {'action': 'test.mock'}}}} + + utils.merge_dicts(overlay['test']['tasks']['task1'], output) + + self._parse_dsl_spec( + add_tasks=False, + changes=overlay, + expect_error=expect_error + ) + def test_policies(self): tests = [ ({'retry': {'count': 3, 'delay': 1}}, False),