diff --git a/.gitignore b/.gitignore index 205f439a..c487c53e 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,7 @@ ENV/ # Generated bogus docs ChangeLog +AUTHORS # build/lint artifacts /charts/shipyard/charts diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index fb4118d2..00000000 --- a/AUTHORS +++ /dev/null @@ -1,14 +0,0 @@ -Alan Meadows -Anthony Lin -Bryan Strassner -Felipe Monteiro -Hassan Kaous -Mark Burnett -One-Fine-Day -Pete Birley -Rodolfo -Scott Hussey -Stacey Fletcher -Tin Lam -Vamsi Krishna Surapureddi -eanylin diff --git a/shipyard_airflow/control/action/action_helper.py b/shipyard_airflow/control/action/action_helper.py index 2c2b573e..0dfca79c 100644 --- a/shipyard_airflow/control/action/action_helper.py +++ b/shipyard_airflow/control/action/action_helper.py @@ -11,9 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" -Common methods for use by action api classes as necessary -""" +""" Common methods for use by action api classes as necessary """ DAG_STATE_MAPPING = { 'QUEUED': 'Pending', @@ -32,18 +30,17 @@ DAG_STATE_MAPPING = { def determine_lifecycle(dag_status=None): - """ - Convert a dag_status to an action_lifecycle value - """ + """ Convert a dag_status to an action_lifecycle value """ if dag_status is None: dag_status = 'NONE' - return DAG_STATE_MAPPING.get(dag_status.upper()) + lifecycle = DAG_STATE_MAPPING.get(dag_status.upper()) + if lifecycle is None: + lifecycle = 'Unknown ({})'.format(dag_status) + return lifecycle def format_action_steps(action_id, steps): - """ - Converts a list of action step database records to desired format - """ + """ Converts a list of action step db records to desired format """ if not steps: return [] steps_response = [] @@ -55,9 +52,7 @@ def format_action_steps(action_id, steps): def format_step(action_id, step, index): - """ - reformat a step (dictionary) into a common response format - """ + """ reformat a step (dictionary) into a common response format """ return { 'url': '/actions/{}/steps/{}'.format(action_id, step.get('task_id')), 'state': step.get('state'), diff --git a/tests/unit/control/test_action_helper.py b/tests/unit/control/test_action_helper.py new file mode 100644 index 00000000..b83334b3 --- /dev/null +++ b/tests/unit/control/test_action_helper.py @@ -0,0 +1,30 @@ +# Copyright 2017 AT&T Intellectual Property. All other rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" Tests for the action_helper.py module """ + +from shipyard_airflow.control.action import action_helper + + +def test_determine_lifecycle(): + dag_statuses = [ + {'input': 'queued', 'expected': 'Pending'}, + {'input': 'ShUTdown', 'expected': 'Failed'}, + {'input': 'RUNNING', 'expected': 'Processing'}, + {'input': 'None', 'expected': 'Pending'}, + {'input': None, 'expected': 'Pending'}, + {'input': 'bogusBroken', 'expected': 'Unknown (bogusBroken)'}, + ] + for status_pair in dag_statuses: + assert(status_pair['expected'] == + action_helper.determine_lifecycle(status_pair['input']))