Ejemplo n.º 1
0
    def test_when_treats_stm_response_country_code_then_notify_server(self):
        network_ctrl = MagicMock()
        ctrl = RobotController(MagicMock(), MagicMock(), network_ctrl,
                               MagicMock())
        ctrl._stm_responses_deque.append(
            commands_from_stm.Feedback(bytearray(b'\xb0\x75\x00\x00')))
        command = {'command': Command.GRAB}
        ctrl._stm_received_queue.put(command)

        ctrl.treat_stm_response()

        network_ctrl.send_country_code.assert_called_once()
Ejemplo n.º 2
0
    def test_when_treats_stm_response_task_failed_then_add_to_todos_to_top_priority(
            self):
        ctrl = RobotController(MagicMock(), MagicMock(), MagicMock(),
                               MagicMock())
        command = {'command': Command.MOVE_FORWARD, 'amplitude': 2222}
        ctrl._stm_received_queue.put(command)
        ctrl._stm_responses_deque.append(
            commands_from_stm.Feedback(
                commands_from_stm.Message.UNSUCCESSFULL_TASK.value))

        ctrl.treat_stm_response()

        self.assertEqual(command, ctrl._stm_commands_todo.popleft())
Ejemplo n.º 3
0
    def test_when_treats_stm_response_task_received_then_add_to_received_queue(
            self):
        ctrl = RobotController(MagicMock(), MagicMock(), MagicMock(),
                               MagicMock())
        command = {'command': Command.MOVE_FORWARD, 'amplitude': 2222}
        ctrl._stm_sent_queue.put(command)
        ctrl._stm_responses_deque.append(
            commands_from_stm.Feedback(
                commands_from_stm.Message.TASK_RECEIVED_ACK.value))

        ctrl.treat_stm_response()

        self.assertEqual(command, ctrl._stm_received_queue.get())
Ejemplo n.º 4
0
    def test_when_treats_stm_response_cube_task_failed_then_notify_server(
            self):
        network_ctrl = MagicMock()
        ctrl = RobotController(MagicMock(), MagicMock(), network_ctrl,
                               MagicMock())
        command = {'command': Command.GRAB}
        ctrl._stm_received_queue.put(command)
        ctrl._stm_responses_deque.append(
            commands_from_stm.Feedback(
                commands_from_stm.Message.TASK_CUBE_FAILED.value))

        ctrl.treat_stm_response()

        network_ctrl.send_feedback.assert_called_once()