Esempio n. 1
0
def test_solve_nok_too_many_letters(capsys):
    job = ["A" for _ in range(wol.SWIPE_LETTERS + 1)]
    chars = len(job)
    usage_feedback = (
        f"ERROR More than {wol.SWIPE_LETTERS} letters given ({chars})")
    assert wol.solve(job) == 2
    out, err = capsys.readouterr()
    assert out.strip() == usage_feedback
Esempio n. 2
0
def test_solve_nok_no_slots(capsys):
    job = ["A" for _ in range(wol.SWIPE_LETTERS)]
    chars = len(job)
    usage_feedback = (
        f"ERROR ({chars}) character{'' if chars == 1 else 's'} given but requested no ({0}) slots () ..."
    )
    assert wol.solve(job) == 2
    out, err = capsys.readouterr()
    assert out.strip() == usage_feedback
Esempio n. 3
0
def test_solve_nok_too_many_words(capsys):
    job = ["A", "B", "C", "D", "E"]
    job.extend(["1"] * (wol.MAX_SLOTS + 1))
    n_slots = [int(n) for n in job[5:]]
    usage_feedback = (
        f'ERROR More than {wol.MAX_SLOTS} slots given ({len(n_slots)})')
    assert wol.solve(job) == 2
    out, err = capsys.readouterr()
    assert out.strip() == usage_feedback
Esempio n. 4
0
def test_solve_nok_no_slots_with_warning(capsys):
    bad = "99"
    job = ["A", "B", bad]
    chars = len(job) - 1
    usage_feedback = (
        f"WARNING Ignoring characters/slot ({bad}) ...\n"
        f"ERROR ({chars}) character{'' if chars == 1 else 's'} given but requested no ({0}) slots () ..."
    )
    assert wol.solve(job) == 2
    out, err = capsys.readouterr()
    assert out.strip() == usage_feedback
Esempio n. 5
0
def test_solve_nok_too_many_slots(capsys):
    job = ["A", "B", "12"]
    chars = len(job[:2])
    n_slots = [int(n) for n in job[2:]]
    sum_slots = sum(n_slots)
    usage_feedback = (
        f'ERROR Only ({chars}) characters given but requested ({sum_slots}) slots ({", ".join(str(n) for n in n_slots)}) ...'
    )
    assert wol.solve(job) == 2
    out, err = capsys.readouterr()
    assert out.strip() == usage_feedback
Esempio n. 6
0
def test_solve_ok_minimal_with_placeholders(capsys):
    wol.LANGUAGE_TEXT_FILE_PATH = LANGUAGE_TEXT_FILE_PATH
    wol.DB_BASE_PATH = DB_BASE_PATH
    word_length = 2
    job = ["a", "t", f"{word_length}", "a", "_"]
    screen_display = ('2 Letters available:\n'
                      '\n'
                      '    a t\n'
                      '\n'
                      'Found 1 candidates of length(2) from letters(a t):\n'
                      '\n'
                      '    0) at')
    assert wol.solve(job) == 0
    out, err = capsys.readouterr()
    assert out.strip() == screen_display
Esempio n. 7
0
def main(argv=None):
    """Process ... TODO."""
    argv = sys.argv[1:] if argv is None else argv
    return solve(argv)