Пример #1
0
    def test_when_execute_stm_tasks_then_send_via_channel(self):
        channel = MagicMock()
        channel.attach_mock(Mock(), 'send_command')
        command = {'command': Command.MOVE_FORWARD, 'amplitude': 2222}
        ctrl = RobotController(MagicMock(), MagicMock(), MagicMock(), channel)
        ctrl._stm_commands_todo.append(command)

        ctrl._execute_stm_tasks()

        channel.send_command.assert_called_once_with(
            StmCommand.factory(command))
Пример #2
0
 def test_when_build_light_led_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.END_SIGNAL})
     self.assertEqual(commands_to_stm.Command.LIGHT_IT_UP.value, command)
Пример #3
0
 def test_when_build_forward_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.MOVE_FORWARD, 'amplitude': 5.0})
     self.assertEqual(b'\x3f\x00\x32', command)
Пример #4
0
 def test_when_build_can_grab_cube_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.CAN_I_GRAB})
     self.assertEqual(commands_to_stm.Command.CAN_GRAB_CUBE.value, command)
Пример #5
0
 def test_when_build_drop_cube_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.DROP})
     self.assertEqual(commands_to_stm.Command.DROP_CUBE.value, command)
Пример #6
0
 def test_when_build_ir_signal_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.INFRARED_SIGNAL})
     self.assertEqual(commands_to_stm.Command.IR_SIGNAL.value, command)
Пример #7
0
 def test_when_build_rotate_counter_clockwise_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.MOVE_ROTATE, 'amplitude': -90.0})
     self.assertEqual(b'\x20\x00\x5a', command)
Пример #8
0
 def test_when_build_right_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.MOVE_RIGHT, 'amplitude': 222.0})
     self.assertEqual(b'\x32\x08\xac', command)
Пример #9
0
 def test_when_build_backward_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.MOVE_BACKWARD, 'amplitude': 20.0})
     self.assertEqual(b'\x3b\x00\xc8', command)
Пример #10
0
 def test_when_build_left_then_correct_syntax(self):
     command = StmCommand.factory({'command': Command.MOVE_LEFT, 'amplitude': 111.0})
     self.assertEqual(b'\x31\x04\x56', command)