def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the Wifi network notifications status...") # Where the information will be stored into the context? variable_to_set = self._pars.save_network_notifications # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't get WiFi network notifications, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) state = self._api.get_network_notification() if state == 1: state = "true" elif state == 0: state = "false" else: msg = "Error returned value get_wifi_network_notifications - %s not supported" % state self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # We have the value, let's save it into the context context.set_info(variable_to_set, state) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( state) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) if self._pars.silent_mode is not None: self._silent_mode = self._pars.silent_mode assert self._pars.frequency in ["AUTO", "2_4GHZ", "5GHZ"], "passed value (%s) is invalid at this stage" % self._pars.frequency self._logger.info("Set frequency band %s for Wifi" % self._pars.frequency) if self._pars.frequency == "2_4GHZ": self._frequency = "2.4GHz" elif self._pars.frequency == "5GHZ": self._frequency = "5GHz" else: self._frequency = "auto" # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't set WiFi frequency band, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._api.set_wifi_frequency_band(self._frequency, silent_mode=self._silent_mode, interface=self._pars.interface) self._wait_until_state_is_reached(self._frequency)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the Wifi interface state...") # Where the information will be stored into the context? variable_to_set = self._pars.save_as value = self._api.get_wifi_power_status() if str_to_bool_ex(value): value = TestConst.STR_ON else: value = TestConst.STR_OFF # We have the value, let's save it into the context context.set_info(variable_to_set, value) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( value) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) # get timeout if any timeout = self._pars.timeout if timeout: self._timeout = timeout self._logger.info( "Timeout set to {0} for setting wifi power".format(timeout)) # Get the power sequence (it might just be one single operation) power = str(self._pars.power).lower() power_sequence = split_and_strip(power, self.STR_SEPARATOR) for current in power_sequence: assert current.lower() in [TestConst.STR_ON, TestConst.STR_OFF], \ "passed value (%s) is invalid at this stage" % current self._logger.info("Powering %s the Wifi interface" % current) self._api.set_wifi_power(current) self._wait_until_state_is_reached(current)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) assert self._pars.power in [ "on", "off" ], "passed value (%s) is invalid at this stage" % self._pars.power hotspot_state = str(self._pars.power).lower() hotspot_hidden = str(self._pars.hidden).lower() # If flight mode is enabled, WiFi Hotspot option is not available if self._api.get_flight_mode() == 1: msg = "Flight mode enabled ! Enabling Hotspot is not possible" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._api.set_wifi_hotspot(hotspot_state, self._pars.ssid, self._pars.security, self._pars.passphrase, self._pars.standard, self._pars.channel, hotspot_hidden) self._wait_until_state_is_reached(hotspot_state)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the WiFi Scan always available status...") # Where the information will be stored into the context? variable_to_set = self._pars.save_scan_always_available state = self._api.get_wifi_scan_always_available() if state not in ["ON", "OFF"]: msg = "ERROR - Unknown WiFi scan always available state : %s" % state self._logger.debug(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # We have the value, let's save it into the context context.set_info(variable_to_set, state) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( state) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the WiFi RSSI...") # Where the information will be stored into the context? variable_to_set = self._pars.save_wifi_rssi # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't get WiFi RSSI, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) current_rssi = self._api.get_wifi_rssi(self._pars.ssid) # We have the value, let's save it into the context context.set_info(variable_to_set, current_rssi) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( current_rssi) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the Wifi Hotspot parameters state...") result_power = self._api.get_wifi_hotspot_status() if str_to_bool_ex(result_power): result_power = "on" else: result_power = "off" result_parameters = self._api.get_wifi_hotspot_parameters() context.set_nested_info([self._pars.wifi_hotspot_parameters, "POWER"], result_power) context.set_nested_info([self._pars.wifi_hotspot_parameters, "SSID"], result_parameters["SSID"]) context.set_nested_info( [self._pars.wifi_hotspot_parameters, "SECURITY"], result_parameters["SECURITY"]) context.set_nested_info( [self._pars.wifi_hotspot_parameters, "PASSPHRASE"], result_parameters["PASSPHRASE"]) context.set_nested_info( [self._pars.wifi_hotspot_parameters, "STANDARD"], result_parameters["STANDARD"]) context.set_nested_info( [self._pars.wifi_hotspot_parameters, "CHANNEL"], result_parameters["CHANNEL"]) context.set_nested_info([self._pars.wifi_hotspot_parameters, "HIDDEN"], result_parameters["HIDDEN"]) self._ts_verdict_msg = "VERDICT: %s stored as {0}:POWER".format( str(self._pars.wifi_hotspot_parameters)) % result_power self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:SSID".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["SSID"] self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:SECURITY".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["SECURITY"] self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:PASSPHRASE".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["PASSPHRASE"] self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:STANDARD".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["STANDARD"] self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:CHANNEL".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["CHANNEL"] self._ts_verdict_msg += "\nVERDICT: %s stored as {0}:HIDDEN".format( str(self._pars.wifi_hotspot_parameters) ) % result_parameters["HIDDEN"] self._logger.debug(self._ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) ssid = str(self._pars.ssid) self._api.wifi_remove_config(ssid)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Scan the Wifi network...") self._api.request_wifi_scan()
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ WifiBase.run(self, context) # remove wifi certificates self._api.remove_wpa_certificates(self._pars.credential_password, self._pars.pin_code_removal)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Set scan always available option for WiFi...") self._api.set_wifi_scan_always_available(self._pars.scan_always_available_state) self._wait_until_state_is_reached(self._pars.scan_always_available_state)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ WifiBase.run(self, context) # Load certificates previously pushed self._api.load_wpa_certificate(self._pars.ca_guard_password, self._pars.certificate_file, self._pars.eap_password, self._pars.credential_password)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) ssid = str(self._pars.ssid) timeout = int(self._pars.timeout) self._logger.info("Wifi connection to %s" % ssid) self._api.wifi_connect(ssid=ssid, check_connection=False) if timeout > 0: self._logger.info( "Check connection state (timeout {0}s)".format(timeout)) self._api.check_connection_state(ssid=ssid, timeout=timeout)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Set regulatory domain for Wifi...") # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't set WiFi regulatory domain, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._api.set_regulatorydomain(self._pars.regulatory_domain, self._pars.interface) self._wait_until_state_is_reached(self._pars.regulatory_domain)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the Wifi frequency band...") # Where the information will be stored into the context? variable_to_set = self._pars.save_frequency_band # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't get WiFi frequency band, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) state = self._api.get_wifi_frequency_band( interface=self._pars.interface) if state == "2.4GHz": state = "2_4GHZ" elif state == "5GHz": state = "5GHZ" elif state == "auto": state = "AUTO" else: msg = "Error returned value get_wifi_frequency_band - %s not supported" % state self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # We have the value, let's save it into the context context.set_info(variable_to_set, state) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( state) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) self._logger.info("Getting the Wifi sleep policy status...") # Where the information will be stored into the context? variable_to_set = self._pars.save_sleep_policy # WiFi must be On to use this function if self._api.get_wifi_power_status() == 0: msg = "Can't get WiFi sleep policy, WiFi is currently OFF" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) state = self._api.get_wifi_sleep_policy() if state not in Constants.WIFI_SLEEP_POLICY_ALL.values(): msg = "Error returned value get_wifi_sleep_policy - %s not supported" % state self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif state == 0: state = "NEVER" elif state == 1: state = "ONLY_WHEN_PLUGGED" elif state == 2: state = "ALWAYS" # We have the value, let's save it into the context context.set_info(variable_to_set, state) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( state) % variable_to_set self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) msg = "All parameters checked :" # # Get the check sequence (it might just be one single operation) state_sequence = split_and_strip(self._pars.state, self.STR_SEPARATOR) for current_state in state_sequence: if current_state == "CONNECTED": ssids = self._api.list_ssids("wifi", "connected") if self._pars.ssid not in ssids: msg = "SSID %s is not connected" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "NOT_CONNECTED": ssids = self._api.list_ssids("wifi", "connected") if self._pars.ssid in ssids: msg = "SSID %s is connected" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "REMEMBERED": ssids = self._api.list_ssids("wifi", "remembered") if self._pars.ssid not in ssids: msg = "SSID %s is not in remembered WiFi AP list" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "NOT_REMEMBERED": ssids = self._api.list_ssids("wifi", "remembered") if self._pars.ssid in ssids: msg = "SSID %s is in remembered WiFi AP list" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "VISIBLE": ssids = self._api.list_ssids("wifi", "visible") if self._pars.ssid not in ssids: msg = "SSID %s is not visible !" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "NOT_VISIBLE": ssids = self._api.list_ssids("wifi", "visible") if self._pars.ssid in ssids: msg = "SSID %s is visible !" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) elif current_state == "ALL": ssids = self._api.list_ssids("wifi", "all") if self._pars.ssid not in ssids: msg = "SSID %s is not known - visible or remembered" % self._pars.ssid self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) else: msg = "Invalid parameter state : %s" % current_state self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Compile verdict message msg += " - %s" % current_state self._logger.debug(msg) self.ts_verdict_msg = msg
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ WifiBase.run(self, context) # # Get the check sequence (it might just be one single operation) state_sequence = split_and_strip(self._pars.state, self.STR_SEPARATOR) msg = "All parameters checked :" self._initial_time = time.time() while not (self._time_out_reached() or self._all_parameters_checked): msg = "All parameters checked :" self._all_parameters_checked = True for current_state in state_sequence: if current_state == "CONNECTED": ssids = self._api.list_ssids("wifi", "connected") if self._pars.ssid not in ssids: self._all_parameters_checked = False elif current_state == "NOT_CONNECTED": ssids = self._api.list_ssids("wifi", "connected") if self._pars.ssid in ssids: self._all_parameters_checked = False elif current_state == "REMEMBERED": ssids = self._api.list_ssids("wifi", "remembered") if self._pars.ssid not in ssids: self._all_parameters_checked = False elif current_state == "NOT_REMEMBERED": ssids = self._api.list_ssids("wifi", "remembered") if self._pars.ssid in ssids: self._all_parameters_checked = False elif current_state == "VISIBLE": ssids = self._api.list_ssids("wifi", "visible") if self._pars.ssid not in ssids: self._all_parameters_checked = False elif current_state == "NOT_VISIBLE": ssids = self._api.list_ssids("wifi", "visible") if self._pars.ssid in ssids: self._all_parameters_checked = False elif current_state == "ALL": ssids = self._api.list_ssids("wifi", "all") if self._pars.ssid not in ssids: self._all_parameters_checked = False else: msg = "Invalid parameter state : %s" % current_state self._logger.error(msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, msg) # Compile verdict message msg += " - %s" % current_state time.sleep(self._wait_for) if self._time_out_reached() and not self._all_parameters_checked: self._raise_device_exception( "Expected SSID State fail : %s - Timeout reached after %ss" % (self._pars.state, self._pars.timeout)) self._logger.debug(msg) self.ts_verdict_msg = msg