Ejemplo n.º 1
0
def test_nested_events(meth, group_index):
    ne_list = NestableEventedList(NEST)
    ne_list.events = Mock(wraps=ne_list.events)

    method_name, args, expected_events = meth
    method = getattr(ne_list[group_index], method_name)
    if method_name == 'index' and group_index != (1, 1):
        # the expected value only occurs in index (1, 1)
        with pytest.raises(ValueError):
            method(*args)
    else:
        # make sure we can call the method without error
        method(*args)

    # make sure the correct event type and number was emitted
    for call, expected in zip(ne_list.events.call_args_list, expected_events):
        event = call.args[0]
        assert event.type == expected
        if group_index == ():
            # in the root group, the index will be an int relative to root
            assert isinstance(event.index, int)
        else:
            assert event.index[:-1] == group_index
Ejemplo n.º 2
0
def test_nested_move_multiple(sources, dest, expectation):
    """Test that moving multiple indices works and emits right events."""
    ne_list = NestableEventedList([0, 1, [20, [210, 211], 22], 3, 4])
    ne_list.events = Mock(wraps=ne_list.events)
    ne_list.move_multiple(sources, dest)
    ne_list.events.reordered.assert_called_with(value=expectation)