Ejemplo n.º 1
0
    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))
Ejemplo n.º 2
0
    def test_merge(self):
        command = self.command
        command.mergeable = True
        other_command = MoveCommand(
            component=self.component,
            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.assertFalse(command.mergeable)
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 def test_do_no_new_position(self):
     with self.assertRaises(TypeError):
         MoveCommand(self.component, previous_position=(50, 50))
Ejemplo n.º 5
0
 def test_do_no_previous_position(self):
     command = MoveCommand(self.component, (25, 25))
     self.assertEqual(command.previous_position, (50, 50))
Ejemplo n.º 6
0
 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))