def test_fuzzy_no_prefix(): # search by distance, no common prefix with any command cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.add_command('user', utils.TestCommand) matches = app.get_fuzzy_matches('uesr') assert matches == ['user']
def test_fuzzy_no_prefix(): # search by distance, no common prefix with any command cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.add_command('user', utils.TestCommand) matches = app.get_fuzzy_matches('uesr') assert matches == ['user']
def test_fuzzy_same_distance(): # searched string has the same distance to all commands cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.add_command('user', utils.TestCommand) for cmd in cmd_mgr.commands.keys(): assert damerau_levenshtein('node', cmd, COST) == 8 matches = app.get_fuzzy_matches('node') assert matches == ['complete', 'help', 'user']
def test_fuzzy_common_prefix(): # searched string is a prefix of all commands cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.commands = {} cmd_mgr.add_command('user list', utils.TestCommand) cmd_mgr.add_command('user show', utils.TestCommand) matches = app.get_fuzzy_matches('user') assert matches == ['user list', 'user show']
def test_fuzzy_same_distance(): # searched string has the same distance to all commands cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.add_command('user', utils.TestCommand) for cmd in cmd_mgr.commands.keys(): assert damerau_levenshtein('node', cmd, COST) == 8 matches = app.get_fuzzy_matches('node') assert matches == ['complete', 'help', 'user']
def test_fuzzy_common_prefix(): # searched string is a prefix of all commands cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.commands = {} cmd_mgr.add_command('user list', utils.TestCommand) cmd_mgr.add_command('user show', utils.TestCommand) matches = app.get_fuzzy_matches('user') assert matches == ['user list', 'user show']
def test_fuzzy_no_commands(): cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.commands = {} matches = app.get_fuzzy_matches('foo') assert matches == []
def test_fuzzy_no_commands(): cmd_mgr = CommandManager('cliff.fuzzy') app = App('test', '1.0', cmd_mgr) cmd_mgr.commands = {} matches = app.get_fuzzy_matches('foo') assert matches == []