Ejemplo n.º 1
0
    def test_redo(self):
        example = SimpleExample(list_value=['foo', 'bar'])

        undo_item = ListUndoItem(
            object=example,
            name='list_value',
            index=1,
            added=['wombat', 'baz'],
            removed=['bar'],
        )

        with self.assertTraitChanges(example, 'list_value_items', count=1):
            undo_item.redo()

        self.assertEqual(example.list_value, ['foo', 'wombat', 'baz'])
Ejemplo n.º 2
0
    def test_merge_equal(self):
        example = SimpleExample(list_value=['foo', 'wombat', 'baz'])
        removed = [['bar']]

        undo_item = ListUndoItem(object=example,
                                 name='list_value',
                                 index=1,
                                 added=[['wombat'], 'baz'],
                                 removed=removed.copy())
        next_undo_item = ListUndoItem(
            object=example,
            name='list_value',
            index=1,
            added=[['wombat'], 'baz'],
            removed=removed.copy(),
        )

        result = undo_item.merge(next_undo_item)

        self.assertFalse(result)
Ejemplo n.º 3
0
    def test_merge_different_index(self):
        example = SimpleExample()
        added = [['wombat'], 'baz']
        removed = [['bar']]

        undo_item = ListUndoItem(
            object=example,
            name='list_value',
            index=1,
            added=added.copy(),
            removed=removed.copy(),
        )
        next_undo_item = ListUndoItem(
            object=example,
            name='any_value',
            index=0,
            added=added.copy(),
            removed=removed.copy(),
        )

        result = undo_item.merge(next_undo_item)

        self.assertFalse(result)
Ejemplo n.º 4
0
    def test_merge_different_undo_item_type(self):
        example_1 = SimpleExample()
        example_2 = SimpleExample()

        undo_item = UndoItem(
            object=example_1,
            name='any_value',
        )
        next_undo_item = ListUndoItem(
            object=example_2,
            name='any_value',
        )

        result = undo_item.merge(next_undo_item)

        self.assertFalse(result)