Esempio n. 1
0
def test_type_error():
    """Test if the method fails on values with no len() attribute."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {1: 42}

    partition_after = {}

    with pytest.raises(TypeError):
        _divide_into_subproblems(partition_before, partition_after)
def test_type_error():
    """Test if the method fails on values with no len() attribute."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {1: 42}

    partition_after = {}

    with pytest.raises(TypeError):
        _divide_into_subproblems(partition_before, partition_after)
def test_splitting():
    """Test if the method splits correctly."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {1: ["A", "B", "C"],
                        2: ["D", "E"],
                        3: ["F"],
                        4: ["G"],
                        5: ["H"]}

    partition_after = {6: ["A", "B"],
                       7: ["C", "D"],
                       8: ["E", "F"],
                       9: ["G"],
                       10: ["I"]}

    match = _divide_into_subproblems(partition_before, partition_after)
    expected_match = [({1: set(['A', 'B', 'C']), 2: set(['D', 'E']),
                        3: set(['F'])},
                       {6: set(['A', 'B']), 7: set(['C', 'D']),
                        8: set(['E', 'F'])}),
                      ({4: set(['G'])}, {9: set(['G'])}),
                      ({5: set(['H'])}, {}),
                      ({}, {10: set(['I'])})]

    assert match == expected_match
def test_empty_value():
    """Test if the method passes empty values correctly."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {1: ["A", "B", "C"],
                        2: []}

    partition_after = {3: ["A", "B"],
                       4: ["C", "D"]}

    match = _divide_into_subproblems(partition_before, partition_after)
    expected_match = [({1: set(['A', 'B', 'C'])},
                       {3: set(['A', 'B']), 4: set(['C', 'D'])}),
                      ({2: set()}, {})]

    assert match == expected_match
Esempio n. 5
0
def test_empty_value():
    """Test if the method passes empty values correctly."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {1: ["A", "B", "C"], 2: []}

    partition_after = {3: ["A", "B"], 4: ["C", "D"]}

    match = _divide_into_subproblems(partition_before, partition_after)
    expected_match = [({
        1: set(['A', 'B', 'C'])
    }, {
        3: set(['A', 'B']),
        4: set(['C', 'D'])
    }), ({
        2: set()
    }, {})]

    assert match == expected_match
Esempio n. 6
0
def test_splitting():
    """Test if the method splits correctly."""
    from beard_server.modules.matching.subproblems import \
        _divide_into_subproblems

    partition_before = {
        1: ["A", "B", "C"],
        2: ["D", "E"],
        3: ["F"],
        4: ["G"],
        5: ["H"]
    }

    partition_after = {
        6: ["A", "B"],
        7: ["C", "D"],
        8: ["E", "F"],
        9: ["G"],
        10: ["I"]
    }

    match = _divide_into_subproblems(partition_before, partition_after)
    expected_match = [({
        1: set(['A', 'B', 'C']),
        2: set(['D', 'E']),
        3: set(['F'])
    }, {
        6: set(['A', 'B']),
        7: set(['C', 'D']),
        8: set(['E', 'F'])
    }), ({
        4: set(['G'])
    }, {
        9: set(['G'])
    }), ({
        5: set(['H'])
    }, {}), ({}, {
        10: set(['I'])
    })]

    assert match == expected_match