def test_apply_to_attributes_delegates_to_correct_function_when_passed_dict(
        mocker):
    mocker.patch.object(graph_operations, 'apply_mapping_to_attributes')
    graph_operations.apply_to_attributes([1, 2, 3], {
        1: 1,
        2: 2,
        3: 3
    }, 'location')
    graph_operations.apply_mapping_to_attributes.assert_called_once_with(
        [1, 2, 3], {
            1: 1,
            2: 2,
            3: 3
        }, 'location')
def test_applying_function_to_attributes():
    d = graph_operations.apply_to_attributes([(1, {
        'a': 2,
        'b': 4
    }), (2, {
        '1': 4,
        '2': 8
    }), (3, {
        'a': 6,
        'b': 10
    })], add_attributes, 'location')
    assert_semantically_equal(d, {1: {'location': 6}, 3: {'location': 16}})
def test_applying_dict_map_to_attributes():
    d = graph_operations.apply_to_attributes([(1, {
        'a': 2,
        'b': 4
    }), (2, {
        'a': 4,
        'b': 8
    }), (3, {
        'a': 6,
        'b': 10
    })], {
        2: 0,
        4: 10
    }, 'a')
    assert_semantically_equal(d, {1: {'a': 0}, 2: {'a': 10}})
def test_apply_to_attributes_delegates_to_correct_function_when_passed_callable(
        mocker):
    mocker.patch.object(graph_operations, 'apply_function_to_attributes')
    graph_operations.apply_to_attributes([1, 2, 3], do_nothing, 'location')
    graph_operations.apply_function_to_attributes.assert_called_once_with(
        [1, 2, 3], do_nothing, 'location')