# Path: awsshell/fuzzy.py
# def fuzzy_search(user_input, corpus):
#     candidates = []
#     for word in corpus:
#         current_score = calculate_score(user_input, word)
#         if current_score > 0:
#             candidates.append((word, current_score))
#     return [c[0] for c in sorted(candidates, key=lambda x: x[1], reverse=True)]


import pytest
from awsshell.fuzzy import fuzzy_search


@pytest.mark.parametrize("search,corpus,expected", [
    ('foo', ['foobar', 'foobaz'], ['foobar', 'foobaz']),
    ('f', ['foo', 'foobar', 'bar'], ['foo', 'foobar']),
    ('fbb', ['foo-bar-baz', 'fo-ba-baz', 'bar'], ['foo-bar-baz', 'fo-ba-baz']),
    ('fff', ['fi-fi-fi', 'fo'], ['fi-fi-fi']),
    # The more chars it matches, the higher the score.
    ('pre', ['prefix', 'pre', 'not'], ['pre', 'prefix']),
    ('nomatch', ['noma', 'nomatccc'], []),
])
def test_subsequences(search, corpus, expected):

# Path: awsshell/fuzzy.py
# def fuzzy_search(user_input, corpus):
#     candidates = []
#     for word in corpus:
#         current_score = calculate_score(user_input, word)
#         if current_score > 0:
#             candidates.append((word, current_score))
#     return [c[0] for c in sorted(candidates, key=lambda x: x[1], reverse=True)]


# Path: tests/unit/test_fuzzy.py
import pytest
from awsshell.fuzzy import fuzzy_search



@pytest.mark.parametrize("search,corpus,expected", [
    ('foo', ['foobar', 'foobaz'], ['foobar', 'foobaz']),
    ('f', ['foo', 'foobar', 'bar'], ['foo', 'foobar']),
    ('fbb', ['foo-bar-baz', 'fo-ba-baz', 'bar'], ['foo-bar-baz', 'fo-ba-baz']),
    ('fff', ['fi-fi-fi', 'fo'], ['fi-fi-fi']),
    # The more chars it matches, the higher the score.
    ('pre', ['prefix', 'pre', 'not'], ['pre', 'prefix']),
    ('nomatch', ['noma', 'nomatccc'], []),
])
def test_subsequences(search, corpus, expected):

    actual = fuzzy_search(search, corpus)