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