Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
Test that correct suggestions occur in all cases where values that
don't match the ones in priority_list or destination_list are used.
  • Loading branch information
Matthew Spelchak committed Feb 16, 2018
1 parent cc8a905 commit 55452b1
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,9 @@ def get_typo_correction(typo_str, word_set, max_dist):
@return: The closest matching string, or None, if no strings
being compared to are within max_dist edit distance.
"""

## Also check by making it lowercase? along with the word set, and if there's a match that's the one we want to suggest?

# Start curr_best out as the largest
# edit distance we will tolerate plus one
curr_best = max_dist + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def test_typo_in_str_default_dest(self, l):
dt.parse_yaml(path=yt.ivYMLTest164, 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', "Default destination 'waffles-Low' does not appear in the job configuration. Did you mean 'waffles_low'?"),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Default destination 'waffles-kow' does not appear in the job configuration. Did you mean 'waffles_low'?"),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

Expand All @@ -812,6 +812,42 @@ def test_typo_in_dict_default_dest(self, l):
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_typo_in_dict_tool_default_dest(self, l):
dt.parse_yaml(path=yt.ivYMLTest166, 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', "Default destination for 'blah': 'waffles_defaut' does not appear in the job configuration. Did you mean 'waffles_default'?"),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_typo_in_str_tool_default_dest(self, l):
dt.parse_yaml(path=yt.ivYMLTest167, 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', "Default destination for 'blah': 'Destination_3_med' does not appear in the job configuration. Did you mean 'Destination3_med'?"),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_typo_in_str_tool_rule_dest(self, l):
dt.parse_yaml(path=yt.ivYMLTest168, 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', "Destination for 'blah', rule 1: 'thig' does not exist in job configuration. Did you mean 'things'? Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

@log_capture()
def test_typo_in_dict_tool_rule_dest(self, l):
dt.parse_yaml(path=yt.ivYMLTest169, 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', "Destination for 'blah', rule 1: 'even_lamerr_cluster' does not exist in job configuration. Did you mean 'even_lamer_cluster'? Ignoring..."),
('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.')
)

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

# Typo in dict tool default destination
ivYMLTest166 = '''
default_destination:
priority:
med: waffles_low
default_priority: med
tools:
blah:
default_destination:
priority:
med: waffles_defaut
rules:
- rule_type: num_input_datasets
nice_value: 0
lower_bound: 0
upper_bound: Infinity
destination: DestinationF
verbose: True
'''

# Typo in str tool default destination
ivYMLTest167 = '''
default_destination: waffles_low
default_priority: waffles_low
tools:
blah:
default_destination: Destination_3_med
rules:
- rule_type: num_input_datasets
nice_value: 0
lower_bound: 0
upper_bound: Infinity
destination: DestinationF
verbose: True
'''

# Typo in dict tool rule destination
ivYMLTest168 = '''
default_destination:
priority:
med: waffles_default
default_priority: med
tools:
blah:
rules:
- rule_type: num_input_datasets
nice_value: 0
lower_bound: 0
upper_bound: Infinity
destination:
priority:
med: thig
verbose: True
'''

# Typo in str tool rule destination
ivYMLTest169 = '''
default_destination:
priority:
med: waffles_default
default_priority: med
tools:
blah:
rules:
- rule_type: num_input_datasets
nice_value: 0
lower_bound: 0
upper_bound: Infinity
destination: even_lamerr_cluster
default_destination:
priority:
med: waffles_default
verbose: True
'''

0 comments on commit 55452b1

Please sign in to comment.