diff options
author | Daniel Rocco <drocco@gmail.com> | 2016-02-14 23:33:23 -0500 |
---|---|---|
committer | Daniel Rocco <drocco@gmail.com> | 2016-02-14 23:33:23 -0500 |
commit | 66f9647210a1f86387c268b84df1af1a31763968 (patch) | |
tree | 7f28613cac20fb72c238eac6bacca0a59355dea2 /tests/test_fuzzy_completion.py | |
parent | 18186f645228a73bf90e75f0397e1947fbb6f61b (diff) |
Use lexical order to break ties when fuzzy matching
Diffstat (limited to 'tests/test_fuzzy_completion.py')
-rw-r--r-- | tests/test_fuzzy_completion.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_fuzzy_completion.py b/tests/test_fuzzy_completion.py index ce148d6b..6b8e6221 100644 --- a/tests/test_fuzzy_completion.py +++ b/tests/test_fuzzy_completion.py @@ -49,3 +49,28 @@ def test_ranking_based_on_shortest_match(completer): matches = completer.find_matches(text, collection) assert matches[1].priority > matches[0].priority + + +@pytest.mark.parametrize('collection', [ + ['user_action', 'user'], + ['user_group', 'user'], + ['user_group', 'user_action'], +]) +def test_should_break_ties_using_lexical_order(completer, collection): + """Fuzzy result rank should use lexical order to break ties. + + When fuzzy matching, if multiple matches have the same match length and + start position, present them in lexical (rather than arbitrary) order. For + example, if we have tables 'user', 'user_action', and 'user_group', a + search for the text 'user' should present these tables in this order. + + The input collections to this test are out of order; each run checks that + the search text 'user' results in the input tables being reordered + lexically. + + """ + + text = 'user' + matches = completer.find_matches(text, collection) + + assert matches[1].priority > matches[0].priority |