def test_when_treat_network_request_then_fills_net_work_request_queue( self): command = { 'command': Command.ACTION, 'actions': [{ 'command': Command.MOVE_BACKWARD, 'amplitude': 18 }, { 'command': Command.MOVE_FORWARD, 'amplitude': 90 }, { 'command': Command.MOVE_LEFT, 'amplitude': 30 }] } ctrl = RobotController(MagicMock(), MagicMock(), MagicMock(), MagicMock()) ctrl._network_request_queue.put(command) ctrl.treat_network_request() self.assertEqual({ 'command': Command.MOVE_BACKWARD, 'amplitude': 18 }, ctrl._stm_commands_todo.popleft()) self.assertEqual({ 'command': Command.MOVE_FORWARD, 'amplitude': 90 }, ctrl._stm_commands_todo.popleft()) self.assertEqual({ 'command': Command.MOVE_LEFT, 'amplitude': 30 }, ctrl._stm_commands_todo.popleft())
def test_when_treats_network_request_then_adds_it_to_stm_todo_queue(self): ctrl = RobotController(MagicMock(), MagicMock(), MagicMock(), MagicMock()) command = {'command': Command.MOVE_FORWARD, 'amplitude': 2222} ctrl._network_request_queue.put(command) ctrl.treat_network_request() self.assertEqual(command, ctrl._stm_commands_todo.pop())