From 7c807d3d82e193403a0ab7411fb0968e6773b9df Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Wed, 7 Feb 2018 13:33:59 -0500 Subject: [PATCH] Tags in workflows were not being properly checked If an invalid tag section was specified, Mistral would throw a 500, with no useful error message. This makes the tags get checked and throws a proper error if so. Change-Id: If2ae69ef76a857bcafe1e4b3d72956c6deeeea09 Closes-Bug: #1747950 --- mistral/lang/v2/workflows.py | 3 ++- mistral/tests/unit/lang/v2/test_workflows.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mistral/lang/v2/workflows.py b/mistral/lang/v2/workflows.py index 6fa7855c8..e4981ec23 100644 --- a/mistral/lang/v2/workflows.py +++ b/mistral/lang/v2/workflows.py @@ -38,7 +38,8 @@ class WorkflowSpec(base.BaseSpec): "input": types.UNIQUE_STRING_OR_ONE_KEY_DICT_LIST, "output": types.NONEMPTY_DICT, "output-on-error": types.NONEMPTY_DICT, - "vars": types.NONEMPTY_DICT + "vars": types.NONEMPTY_DICT, + "tags": types.UNIQUE_STRING_LIST }, "required": ["tasks"], "additionalProperties": False diff --git a/mistral/tests/unit/lang/v2/test_workflows.py b/mistral/tests/unit/lang/v2/test_workflows.py index a0301c5b2..e5027ab70 100644 --- a/mistral/tests/unit/lang/v2/test_workflows.py +++ b/mistral/tests/unit/lang/v2/test_workflows.py @@ -425,3 +425,22 @@ class WorkflowSpecValidation(base.WorkflowSpecValidationTestCase): "Workflow name cannot be in the format of UUID", str(exception) ) + + def test_tags(self): + tests = [ + ({'tags': ''}, True), + ({'tags': []}, True), + ({'tags': ['']}, True), + ({'tags': ['tag']}, False), + ({'tags': ['tag', 'tag']}, True), + ({'tags': None}, True) + ] + + for wf_tags, expect_error in tests: + overlay = {'test': wf_tags} + + self._parse_dsl_spec( + add_tasks=True, + changes=overlay, + expect_error=expect_error + )