def test_merge_unmergeable(self): command = self.command other_command = ResizeCommand(component=self.component, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25, 150, 150))
def test_merge_other_mergeable(self): command = self.command command.mergeable = True other_command = ResizeCommand(component=self.component, mergeable=True, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitChanges(command, 'data'): merged = command.merge(other_command) self.assertTrue(merged) self.assertEqual(command.data, (0, 0, 200, 200)) self.assertTrue(command.mergeable)
def test_move_command_no_previous_position(self): command = ResizeCommand.move_command(self.component, (25, 25)) self.assertEqual(command.data, (25, 25, 100, 100)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100))
def test_do_no_new_position_no_previous_position_with_data(self): command = ResizeCommand(self.component, data=(25, 25, 150, 150)) self.assertEqual(command.data, (25, 25, 150, 150)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100))
def test_do_no_new_position(self): with self.assertRaises(TypeError): ResizeCommand(self.component, previous_rectangle=(50, 50, 100, 100))
def test_do_no_previous_rectangle(self): command = ResizeCommand(self.component, (25, 25, 150, 150)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100))
def setUp(self): self.component = Component(position=[50, 50], bounds=[100, 100]) self.component.request_redraw = MagicMock() self.command = ResizeCommand(self.component, (25, 25, 150, 150), (50, 50, 100, 100))