Skip to content

Commit

Permalink
Alter error messages, add new tests
Browse files Browse the repository at this point in the history
A few error messages were altered to start with lowercase letters.
Why? Don't ask me, that was yesterday. Expect all the error
messages to be altered to start with capitals (as I believe they
should) soon.

Two new tests were added, ensuring that errors are fired when
priorities are referenced that don't appear in the config's global
default_destinaion section.
  • Loading branch information
Matthew Spelchak committed Feb 6, 2018
1 parent 4f47980 commit ec3bb7d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def __validate_destination(cls, valid_rule, return_bool, rule, tool, counter):

for priority in rule["destination"]["priority"]:
if priority not in priority_list:
error = "Invalid priority '"
error = "invalid priority '"
error += str(priority) + "' for rule "
error += str(counter) + " in '" + str(tool) +"'."
if not return_bool:
Expand Down Expand Up @@ -941,22 +941,22 @@ def infinite_defaultdict():
log.debug(error)
valid_config = False
else:
error = ("No default '" + str(priority) +
error = ("no default '" + str(priority) +
"' priority destination for tool " +
str(tool) + " in config!")
if verbose:
log.debug(error)
valid_config = False

else:
error = ("Invalid default priority '" +
str(priority) + "' for " + str(tool) +
" found in config!")
error = ("invalid default destination priority '" +
str(priority) + "' for '" + str(tool) +
"'.")
if verbose:
log.debug(error)
valid_config = False
else:
error = "No default priority destinations specified"
error = "no default priority destinations specified"
error += " for " + str(tool) + " in config!"
if verbose:
log.debug(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def test_tool_without_low_default_destination(self, l):
dt.parse_yaml(path=yt.ivYMLTest146, test=True)
l.check(
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Invalid priority 'low' for rule 1 in 'smalt'. Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "invalid priority 'low' for rule 1 in 'smalt'. Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

Expand All @@ -660,7 +660,7 @@ def test_tool_with_invalid_priority_destination(self, l):
dt.parse_yaml(path=yt.ivYMLTest147, test=True)
l.check(
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Invalid priority 'mine' for rule 1 in 'smalt'. Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "invalid priority 'mine' for rule 1 in 'smalt'. Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

Expand Down Expand Up @@ -730,6 +730,24 @@ def test_default_destination_without_priority_not_in_job_conf(self, l):
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_tool_rule_priority_does_not_exist(self, l):
dt.parse_yaml(path=yt.ivYMLTest156, test=True)
l.check(
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "invalid priority 'notAPriority' for rule 1 in 'aTool'. Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_tool_default_destination_priority_does_not_exist(self, l):
dt.parse_yaml(path=yt.ivYMLTest157, test=True)
l.check(
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "invalid default destination priority 'notAPriority' for 'aTool'."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

# ================================Valid yaml files==============================
@log_capture()
def test_parse_valid_yml(self, l):
Expand Down
35 changes: 35 additions & 0 deletions test/unit/jobs/dynamic_tool_destination/ymltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,3 +1063,38 @@
default_destination: no_such_dest
verbose: True
'''

# tool rule destination priority doesn't exist
ivYMLTest156 = '''
default_destination:
priority:
med: waffles_default
tools:
aTool:
default_destination:
priority:
med: waffles_low
rules:
- rule_type: num_input_datasets
nice_value: 0
lower_bound: 0
upper_bound: Infinity
destination:
priority:
notAPriority: waffles_default
verbose: True
'''

# tool default destination priority doesn't exist
ivYMLTest157 = '''
default_destination:
priority:
med: waffles_default
tools:
aTool:
default_destination:
priority:
notAPriority: waffles_low
med: waffles_low
verbose: True
'''

0 comments on commit ec3bb7d

Please sign in to comment.