Beispiel #1
0
 def get_data_connection_status(self):
     """
     Gets data connection status.
     :rtype: str
     :return: the data connection status. Possible returned values:
         - "IDLE"
         - "ATTACHING"
         - "DETACHING"
         - "ATTACHED"
         - "STARTING"
         - "ENDING"
         - "TRANSFERRING"
         - "PDP_ACTIVATING"
         - "PDP_ACTIVE"
         - "PDP_DEACTIVATING"
         - "CS_DATA_CON_ACTIVE"
         - "SUSPENDED"
     """
     (err, status, msg) = W.GetDataConnectionStatus(self.get_root())
     self.__error_check(err, msg)
     return status
Beispiel #2
0
    def check_data_connection_transferring_time(self,
                                                transferring_timeout,
                                                transferring_time,
                                                check_ota_throughput=False,
                                                blocking=True):
        """
        Check data connection, looking for "transferring" state.

        :type transferring_timeout: integer
        :param transferring_timeout: allowed time in seconds to reach 'transferring' state

        :type transferring_time: integer
        :param transferring_time: time in seconds of continuous transfer

        :type check_ota_throughput: boolean
        :param check_ota_throughput: boolean defining if check is done on Over The Air
        throughputs (True) or IP throughput (False).

        :type blocking: boolean
        :param blocking: boolean defining if the function is blocking (returns
        an Exception) or not (returns True or False)

        :rtype: boolean
        :return: True if state is reached, else returns False

        .. warning:: check_ota_throughput set to True will
        test connection by checking OTA throughputs (Tx and Rx),
        whereas check_ota_throughput set to False will test connection
        by checking IP throughputs (Tx and Rx).
        """
        timer = transferring_timeout
        self.get_logger().info(\
            "Check if there is a continuous data transfer during %d seconds before %d seconds" \
            % (transferring_time, transferring_timeout))

        (err, current_state, msg) = W.GetDataConnectionStatus(self.get_root())
        self.__error_check(err, msg)
        transfer_count = 0

        while timer > 0:
            time.sleep(1)
            (err, current_state, msg) = \
                W.GetDataConnectionStatus(self.get_root())
            self.__error_check(err, msg)

            if (current_state == "TRANSFERRING"):
                transfer_count += 1
            else:
                transfer_count = 0
            timer -= 1
            if transfer_count >= transferring_time:
                self.get_logger().info(
                    "Continuous data transfer during %d seconds has been reached",
                    transferring_time)
                return True

        if blocking:
            # Failed to transfer data continuously
            msg = "Failed to transfer data continuously during %d seconds!" % transferring_time
            self.get_logger().error(msg)
            raise TestEquipmentException(
                TestEquipmentException.TIMEOUT_REACHED, msg)
        else:
            # Failed to transfer data continuously (Test failed no TestEquipmentException raised)
            self.get_logger().error(
                "Failed to transfer data continuously during %d seconds!" %
                transferring_time)
        return False
Beispiel #3
0
    def check_data_connection_state(self,
                                    state,
                                    timeout=0,
                                    blocking=True,
                                    cell_id=None):
        """
        Checks that the data connection is set at the required state
        before the given timeout. If timeout is <= 0, only one test is performed.
        :raise TestEquipmentException: the required status has not been reached before the timeout
        :type state: str
        :param state: the expected state. Possible values:
            - "ATTACHED"
            - "PDP_ACTIVE"
            - "TRANSFERRING"
            - "SUSPENDED"
        :type timeout: integer
        :param timeout: allowed time to reach expected state
        :type blocking: boolean
        :param blocking: boolean to know if the function raises an error
        or simply return true or false if the status is reached or not
        :rtype: boolean
        :return: True if state is reached, else returns False
        :type cell_id : str
        :param cell_id: cell used for the test. Possible values:
            - "A"
            - "B"
        .. warning:: This parameter is only used in 4G (LTE)
        """
        attached = False
        timer = timeout
        self.get_logger().info("Check data connection is %s before %d seconds",
                               state, timeout)

        (err, current_state, msg) = W.GetDataConnectionStatus(self.get_root())
        self.__error_check(err, msg)

        while (timer > 0) and (current_state != state):
            if state == "ATTACHED" and current_state == "PDP_ACTIVE":
                attached = True
                break
            time.sleep(1)
            (err, current_state, msg) = \
                W.GetDataConnectionStatus(self.get_root())
            self.__error_check(err, msg)
            timer -= 1

        if current_state != state and not attached:
            if blocking:
                # Failed to reach desired state
                msg = "Failed to reach %s data state!" % state
                self.get_logger().error(msg)
                raise TestEquipmentException(
                    TestEquipmentException.TIMEOUT_REACHED, msg)
            else:
                # Failed to reach desired state (Test failed no TestEquipmentException raised)
                self.get_logger().error("Failed to reach %s data state!",
                                        state)

            return False
        else:
            self.get_logger().info(
                "Data connection is %s and has been reached in %d seconds" %
                (current_state, timeout - timer))
            return True