def test_undo_one_insert(self):
        change_log = [
            [ 'previous' ], [ 'changes' ],  # these remain untouched
            [ Insert(R(1, 1, 1, 1)) ],  # undoes only last changelist
        ]
        model_elems = [ R(3, 3, 3, 3), R(1, 1, 1, 1), R(2, 2, 2, 2) ]
        redo_log = [ [ 'future' ], [ 'changes'] ]

        _undo(change_log, redo_log, self.eb, model_elems)

        assert change_log == [
            [ 'previous' ], [ 'changes' ],
        ]
        assert redo_log == [
            [ Insert(R(1, 1, 1, 1)) ],
            [ 'future' ], [ 'changes'],
        ]
        assert model_elems == [ R(3, 3, 3, 3), R(2, 2, 2, 2) ]

        assert len(self.event_log) == 1
        assert self.event_log[-1].data == [ Remove(R(1, 1, 1, 1)) ]  # inverted
    def test_undo_one_remove(self):
        change_log = [
            [ 'previous' ], [ 'changes' ],
            [ Remove(R(1, 1, 1, 1)) ],
        ]
        model_elems = [ R(2, 2, 2, 2) ]
        redo_log = [ [ 'future' ], [ 'changes'] ]

        _undo(change_log, redo_log, self.eb, model_elems)

        assert change_log == [
            [ 'previous' ], [ 'changes' ],
        ]
        assert redo_log == [
            [ Remove(R(1, 1, 1, 1)) ],
            [ 'future' ], [ 'changes'],
        ]
        assert model_elems == [ R(2, 2, 2, 2), R(1, 1, 1, 1) ]

        assert len(self.event_log) == 2
        assert self.event_log[-1].data == [ Insert(R(1, 1, 1, 1)) ]  # inverted
    def test_undo_one_modify(self):
        change_log = [
            [ 'previous' ], [ 'changes' ],
            [ Modify(R(3, 3, 3, 3), R(1, 1, 1, 1)) ],
        ]
        model_elems = [ R(1, 1, 1, 1), R(2, 2, 2, 2) ]
        redo_log = [ [ 'future' ], [ 'changes'] ]

        _undo(change_log, redo_log, self.eb, model_elems)

        assert change_log == [
            [ 'previous' ], [ 'changes' ],
        ]
        assert redo_log == [
            [ Modify(R(3, 3, 3, 3), R(1, 1, 1, 1)) ],
            [ 'future' ], [ 'changes'],
        ]
        assert model_elems == [ R(3, 3, 3, 3), R(2, 2, 2, 2) ]

        assert len(self.event_log) == 3
        assert self.event_log[-1].data == [ Modify(R(1, 1, 1, 1),
                                                   R(3, 3, 3, 3)) ]  # inverted