Пример #1
0
def test_solve_returns_list():
    expected_results = get_all_combinations(["Dog", "Cat", "Mouse"])

    r = RankingProblem()
    r.set_items(["Dog", "Cat", "Mouse"])
    actual_results = r.solve()

    assert(actual_results == expected_results)
def test_get_all_combinations_excluding_supplied_correct():
    expected_results = [
        (
            "Blue",
            "Red",
        ),
    ]

    actual_results = get_all_combinations(["Red", "Blue"], False)
    assert (actual_results == expected_results)
def test_get_all_combinations_excluding_supplied_incorrect():
    unexpected_results = [
        (
            "Red",
            "Blue",
        ),
    ]

    actual_results = get_all_combinations(["Red", "Blue"], False)

    for unexpected_item in unexpected_results:
        with pytest.raises(ValueError, match=r".*is not in list"):
            actual_results.index(unexpected_item)
def test_get_all_combinations_correct():
    expected_results = [
        (
            "Blue",
            "Red",
        ),
        (
            "Red",
            "Blue",
        ),
    ]

    actual_results = get_all_combinations(["Red", "Blue"])
    assert (actual_results == expected_results)
Пример #5
0
def test_solve_is_before_fully_specified_incorrect():
    unexpected_results = get_all_combinations(["Mouse", "Cat", "Dog"],
                                              include_passed_values=False)

    r = RankingProblem()
    r.set_items(["Dog", "Cat", "Mouse"])
    r.is_before("Cat", "Dog")
    r.is_before("Mouse", "Cat")

    actual_results = r.solve()

    for actual_result in actual_results:
        for unexpected_result in unexpected_results:
            assert (unexpected_result != actual_result)
def test_get_all_combinations_correct_but_out_of_sequence():
    expected_results_out_of_sequence = [
        (
            "Red",
            "Blue",
        ),
        (
            "Blue",
            "Red",
        ),
    ]

    actual_results = get_all_combinations(["Red", "Blue"])
    assert (actual_results != expected_results_out_of_sequence)
    assert (actual_results[0] == expected_results_out_of_sequence[1])
    assert (actual_results[1] == expected_results_out_of_sequence[0])
def test_get_all_combinations_empty():
    empty_results = [()]

    assert (get_all_combinations([]) == empty_results)
def test_can_call_get_all_combinations():
    get_all_combinations(["Red", "Blue"])