Skip to content

Commit

Permalink
Fix error message order, add test
Browse files Browse the repository at this point in the history
Fixed some error message logic. Previously, a tool_destinations.yml config
with an empty priority key in global 'default_destination' would throw two
errors in a strange order; one about no valid default priority destinations,
and another about no default destination. This has been changed so with the
same config there is now just a 'No default destinations in config' message.

Also added a test that confirms this behaviour
  • Loading branch information
Matthew Spelchak committed Feb 12, 2018
1 parent 4c402b3 commit cdcd07f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
50 changes: 25 additions & 25 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,37 +842,37 @@ def infinite_defaultdict():
if verbose:
log.debug(error)
valid_config = False

else:
error = "No default priority destinations specified in config!"
if verbose:
log.debug(error)
valid_config = False

if 'default_priority' in obj:
if isinstance(obj['default_priority'], str):
if obj['default_priority'] in priority_list:
new_config['default_priority'] = obj['default_priority']
else:
if 'default_priority' in obj:
if isinstance(obj['default_priority'], str):
if obj['default_priority'] in priority_list:
new_config['default_priority'] = obj['default_priority']
else:
error = ("Default priority '" + str(obj['default_priority'])
+ "' is not a valid priority.")
if verbose:
log.debug(error)
else:
error = "default_priority in config is not valid."
if verbose:
log.debug(error)
valid_config = False
else:
error = ("Default priority '" + str(obj['default_priority'])
+ "' is not a valid priority.")
error = "No default_priority section found in config."
if 'med' in priority_list:
error += " Setting 'med' as default priority."
new_config['default_priority'] = 'med'
else:
error += " Things may not run as expected!"
valid_config = False
if verbose:
log.debug(error)
else:
error = "default_priority in config is not valid."
if verbose:
log.debug(error)
valid_config = False

else:
error = "No default_priority section found in config."
if 'med' in priority_list:
error += " Setting 'med' as default priority."
new_config['default_priority'] = 'med'
else:
error += " Things may not run as expected!"
valid_config = False
error = "No global default destinations specified in config!"
if verbose:
log.debug(error)
valid_config = False
else:
error = "No global default destination specified in config!"
if verbose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,15 @@ def test_tool_default_destination_without_priority_not_in_job_conf(self, l):
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_tool_default_destination_without_priority_not_in_job_conf(self, l):
dt.parse_yaml(path=yt.ivYMLTest162, job_conf_path=job_conf_path, test=True)
l.check(
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "No global default destinations specified in config!"),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

# ================================Valid yaml files==============================
@log_capture()
def test_parse_valid_yml(self, l):
Expand Down
6 changes: 6 additions & 0 deletions test/unit/jobs/dynamic_tool_destination/ymltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,3 +1162,9 @@
med: waffles_default
verbose: True
'''
# Nothing in the priority dict
ivYMLTest162 = '''
default_destination:
priority:
verbose: True
'''

0 comments on commit cdcd07f

Please sign in to comment.