MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / test_undo_redo_cycle

Method test_undo_redo_cycle

tests/test_command_system.py:148–173  ·  view source on GitHub ↗

Test complete undo/redo cycle.

(self)

Source from the content-addressed store, hash-verified

146 self.assertEqual(self.history.get_command_count(), 1)
147
148 def test_undo_redo_cycle(self):
149 """Test complete undo/redo cycle."""
150 cmd1 = MockCommand("Command 1")
151 cmd2 = MockCommand("Command 2")
152
153 # Execute commands
154 self.history.execute_command(cmd1)
155 self.history.execute_command(cmd2)
156
157 # Should be able to undo
158 self.assertTrue(self.history.can_undo())
159 self.assertEqual(self.history.get_undo_description(), "Command 2")
160
161 # Undo last command
162 undone = self.history.undo()
163 self.assertEqual(undone, "Command 2")
164 self.assertEqual(cmd2.undo_count, 1)
165
166 # Should be able to redo
167 self.assertTrue(self.history.can_redo())
168 self.assertEqual(self.history.get_redo_description(), "Command 2")
169
170 # Redo command
171 redone = self.history.redo()
172 self.assertEqual(redone, "Command 2")
173 self.assertEqual(cmd2.execute_count, 2) # Executed twice
174
175 def test_depth_limit_enforcement(self):
176 """Test that command history respects depth limits."""

Callers

nothing calls this directly

Calls 8

MockCommandClass · 0.70
execute_commandMethod · 0.45
can_undoMethod · 0.45
get_undo_descriptionMethod · 0.45
undoMethod · 0.45
can_redoMethod · 0.45
get_redo_descriptionMethod · 0.45
redoMethod · 0.45

Tested by

no test coverage detected