Example #1
0
 def set_ua_token(self, ua_token):
     """
     Sets 'UA token' for current instance of User class
     :param ua_token: - string value of 'UA token' obtained from Cloud
     """
     self._ua_token = ua_token
     logger.info(u"User: {0} {1} - UA Token set to:\n{2}\n".format(self._name, self._surname, ua_token))
Example #2
0
 def set_account_name(self, account_name):
     """
     Sets 'account_name' of user for current instance of User class
     :param account_name: - string value of user's 'account_name'
     """
     self._account_name = account_name
     logger.info(u"User: {0} {1} - account_name set to: {2}".format(self._name, self._surname, account_name))
def family_member_location_send_location_package(params):
    new_snapshot = InputParameterConvertor.convert_to_bool(
        params['new_snapshot'])

    zone_id = variables.logged_user.values()[0].get_primary_zone()['zoneId']
    plugin_type = InputParameterConvertor.check_valid_parameter(
        params['plugin_type'], ["Status", "Detail"])
    if plugin_type == "Status":
        content_data = LayoutNoticeContentData.data_for_layout_with_json_data(
            "service_package", {"users": []})
        content = NoticeContentData.create_content_data(
            content_id="status.low",
            origin_plugin_id="service",
            id_="1",
            zone_id=zone_id,
            content=content_data)
    else:  # Detail
        content_data = LayoutNoticeContentData.data_for_layout_with_json_data(
            "plugin_detail_package", {"users": []})
        content = NoticeContentData.create_content_data(
            content_id="detail.low",
            origin_plugin_id="service",
            id_="1",
            zone_id=zone_id,
            content=content_data)

    try:
        variables.contents
    except AttributeError:
        variables.contents = {}

    variables.contents[params['plugin_type']] = content

    increment = True
    try:
        variables.contentIncrementVersion
    except AttributeError:
        increment = False

    if increment is False or new_snapshot:
        variables.contentIncrementVersion = 0
        increment = False
    else:
        variables.contentIncrementVersion += 1

    content_change_message = ZplZplContentOnChange.create_message(
        increment=increment,
        version=variables.contentIncrementVersion,
        add=[content])

    # generate and send request
    request_command = SendRequest.create_command(
        message_id="zpl.Zpl.Content.OnChange",
        message_data=content_change_message)

    check_command = variables.sim.send(request_command)
    variables.sim.check_ack(check_command)
    logger.info("zpl.Zpl.Content.OnChange command was sent successfully.")

    execution.passed()
Example #4
0
 def set_zones(self, zones):
     """
     Sets 'zones' of user for current instance of User class
     :param zones: - array of user's 'zones' [{"role": "admin" / "user", "type": "primary" / "secondary", "zoneId": "{zone identifier}"}]
     """
     self._zones = zones
     logger.info(u"User: {0} {1} - zones set to: {2}".format(self._name, self._surname, zones))
def family_member_location_element_on_card_displayed(params):
    element_name = InputParameterConvertor.check_valid_parameter(
        params['element_name'].upper(), ['ADDRESS', 'TIMESTAMP'])
    user = variables.users[params['user']]

    label_to_search = user.get_name()
    if label_to_search == variables.logged_user.values()[0].get_name():
        label_to_search = 'Me'

    try:
        if element_name == 'ADDRESS':
            variables.dashboard_screen.get_plugin_status_object_at_index_for_user_name(
                user_name=label_to_search, plugin_index=1)
        elif element_name == 'TIMESTAMP':
            variables.dashboard_screen.get_plugin_detail_object_at_index_for_user_name(
                user_name=label_to_search, plugin_index=1)
    except LookupError:
        execution.error(
            "The element {0} was not found in location card for user {1}.".
            format(element_name, label_to_search))

    logger.info(
        "The element {0} is displayed in location card for user {1}.".format(
            element_name, user.get_name()))
    execution.passed()
Example #6
0
 def set_relations(self, relations):
     """
     Sets 'relations' of user for current instance of User class
     :param relations: - array of user's 'relations' [{ "type": "managedby" /  "masterof", "accountId": "{user account identifier}"}]
     """
     self._relations = relations
     logger.info(u"User: {0} {1} - relations set to: {2}".format(self._name, self._surname, relations))
Example #7
0
 def set_zaapas_untrusted_token(self, zaapas_untrusted_token):
     """
     Sets 'Zaapas untrusted token' for current instance of User class
     :param zaapas_untrusted_token: - string value of 'Zaapas untrusted token' obtained from Cloud
     """
     self._zaapas_untrusted_token = zaapas_untrusted_token
     logger.info(u"User: {0} {1} - Zaapas Untrusted Token set to:\n{2}\n".format(self._name, self._surname, zaapas_untrusted_token))
def family_member_location_check_opened_status_for_service(params):
    user = variables.users[params['user']]
    location_text = LocationToAddress.location_to_address(
        variables.locations_of_users[user.get_account_id()]["data"]).encode(
            'utf-8')
    plugin_expected_displayed = InputParameterConvertor.convert_to_bool(
        params['bool'])

    user_name = user.get_name()
    if user_name == variables.logged_user.values()[0].get_name():
        logger.info(
            "{0} is the logged user, searching plugins for user name: Me".
            format(params['user']))
        user_name = 'Me'

    logger.info(
        "User object for {0} found, searching location plugin: {1} for user name: {2}"
        .format(params['user'], location_text, user_name))

    all_cards = variables.dashboard_screen.all_cards_on_dashboard
    all_cards_names = all_cards.get_list(True)
    if user_name not in all_cards_names:
        execution.error(
            "User with name: {0} not found on dashboard! Found only cards: {1}"
            .format(user_name, all_cards_names))

    user_index = all_cards.get_index(user_name)
    all_users_names = [user.get_name() for user in variables.users.values()]
    plugin_displayed = None
    if len(all_cards_names) > user_index + 1:
        for i in xrange(user_index + 1, len(all_cards_names)):
            diff = compare_values(all_cards_names[i], location_text)
            if diff:
                logger.info(
                    "Comparing plugin no.{0}... Plugin does not match expected value:\n{1}"
                    .format(str(i - user_index), diff))
            else:
                plugin_displayed = True
                logger.info(
                    "Comparing plugin no.{0}... Plugin matches expected value: {1}"
                    .format(str(i - user_index), location_text))
                break

            # there is another user (==no more plugins for current user) or no more cards
            if all_cards_names[i] in all_users_names or i == (
                    len(all_cards_names) - 1):
                plugin_displayed = False
                logger.info(
                    "Plugin: {0} not found in {1} plugin card(s) for user: {2}"
                    .format(location_text, str(i - user_index), user_name))
    else:
        plugin_displayed = False

    if plugin_displayed != plugin_expected_displayed:
        execution.error(
            "Plugin displayed == {0}, expected state == {1}! Check debug logs for more info..."
            .format(plugin_displayed, plugin_expected_displayed))

    execution.passed()
Example #9
0
 def set_password(self, password):
     """
     Sets 'password' of user for current instance of User class
     :type password PasswordStrength
     :param password: - password strength (must be PasswordStrength type)
     """
     self._password = self.get_password_strength(password)
     logger.info(u"User: {0} {1} - Password strength set to: {2} ({3})".format(self._name, self._surname, password.name, self._password))
Example #10
0
    def _wifi_turn_on(self):
        if InputParameterConvertor.convert_to_int(
                self._button_wifi.get_attribute('value')) == 1:
            logger.warning("Trying to turn Wi-Fi ON, but Wi-Fi is already ON!")
        else:
            self._button_wifi.click()

        logger.info("Wi-Fi state: ON")
Example #11
0
 def set_account_id(self, account_id):
     """
     Sets 'account id' for current instance of User class
     :param account_id: - string value of 'account id' obtained from Cloud
     """
     self._account_id = account_id
     logger.info(u"User: {0} {1} - Account ID set to:\n{2}\n".format(self._name, self._surname, account_id))
     self._set_account_id_in_device_info(account_id)
     logger.info(u"User: {0} {1} - All devices owner Account ID updated".format(self._name, self._surname))
Example #12
0
    def _airplane_mode_turn_on(self):
        if InputParameterConvertor.convert_to_int(
                self._button_airplane_mode.get_attribute('value')) == 1:
            logger.warning(
                "Trying to turn Airplane Mode ON, but Airplane Mode is already ON!"
            )
        else:
            self._button_airplane_mode.click()

        logger.info("Airplane Mode state: ON")
Example #13
0
 def _open_control_center(self):
     """
     Opens up iOS Control Center by swiping from the bottom to the top of the screen.
     """
     self._driver.swipe(start_x=self._horizontal_center,
                        start_y=self._screen_bottom,
                        end_x=self._horizontal_center,
                        end_y=self._screen_top,
                        duration=500)
     self._button_airplane_mode.wait_for(5)
     logger.info("iOS Control Center has been opened.")
Example #14
0
    def add_devices(self, devices):
        """
        Add 'devices' to the 'devices_list' currently held in this instance of class User
        :param devices: - desired device or list of devices to be added (enum type of AndroidDeviceType or IosDeviceType required)
        """
        new_devices = self._get_devices_info_from_files(self._process_input_device_type(devices))
        self._devices_list.update(new_devices)
        for device in new_devices:
            logger.info(u"User: {0} {1} - Adding device: {2}".format(self._name, self._surname, device))

        # Update all devices with current account_id
        self._set_account_id_in_device_info(self._account_id)
Example #15
0
    def __custom_ios_clear_password(self):

        if self.edit_text_password.get_text() == self.PASSWORD_PLACEHOLDER:
            logger.info("Password text field is empty!")
            return

        self.edit_text_password.click()

        i = len(self.edit_text_password.get_text())
        while i != 0:
            self.edit_text_password.set_text("\b")
            i -= 1
Example #16
0
 def _close_control_center(self):
     """
     Closes iOS Control Center by tapping on iOS status bar (the bar on the top of the screen).
     """
     self._driver.execute_script(
         "mobile: tap", {
             "tapCount": 1,
             "touchCount": 1,
             "duration": 0.2,
             "x": self._horizontal_center,
             "y": self._screen_top
         })
     logger.info("iOS Control Center has been closed.")
Example #17
0
    def set_zone(self, zone_id, zone_type, user_role):
        """
        Sets/adds zone data to user zone
        """
        for zone in self._zones:
            if zone['zoneId'] == zone_id:
                zone['type'] = zone_type
                zone['role'] = user_role
                logger.info(u"User: {0} {1} - updated zone (type:{2} role:{3}, zoneId:{4})".format(self._name, self._surname, zone_type, user_role, zone_id))
                return

        self._zones.append({'type': 'primary', 'role': user_role, 'zoneId': zone_id})
        logger.info(u"User: {0} {1} - added zone (type:{2} role:{3}, zoneId:{4})".format(self._name, self._surname, type, user_role, zone_id))
Example #18
0
 def set_device_id(self, device, device_id):
     """
     Sets new Device ID (obtained from Cloud) to device info
     :param device: - device which information shall be updated(enum type of AndroidDeviceType or IosDeviceType required)
     :param device_id: - new device id
     """
     if type(device) is AndroidDeviceType or type(device) is IosDeviceType:
         if device in self._devices_list:
             self._devices_list[device]["deviceId"] = device_id
             logger.info(u"User: {0} {1} - New device ID set for:\n{2}\n".format(self._name, self._surname, device))
         else:
             raise KeyError(u"User: {0} {1} - Setting Current device failed. {2} is not amongst devices in devices list".format(self._name, self._surname, device))
     else:
         raise TypeError(u"User: {0} {1} - Setting Current device failed. Parameter accepts only single AndroidDeviceType or IosDeviceType item".format(self._name, self._surname))
Example #19
0
 def set_device_name(self, device, name):
     """
     Sets new name into device information
     :param device: - specified device which information shall be updated (enum type of AndroidDeviceType or IosDeviceType required)
     :param name: - new name of device (must be string type)
     """
     if type(device) is AndroidDeviceType or type(device) is IosDeviceType:
         if device in self._devices_list:
             self._devices_list[device]["name"] = name
             logger.info(u"User: {0} {1} - New device name: {2} set to: {3}".format(self._name, self._surname, device.name, name))
         else:
             raise KeyError(u"User: {0} {1} - Setting Current device failed. {2} is not amongst devices in devices list".format(self._name, self._surname, device))
     else:
         raise TypeError(u"User: {0} {1} - Setting device name failed. Parameter 'device' accepts only single AndroidDeviceType or IosDeviceType item".format(self._name, self._surname))
Example #20
0
    def remove_devices(self, devices):
        """
        Remove 'devices' from 'device_list' currently held in this instance of class User
        :param devices: - desired device or list of devices to be removed from 'devices_list'
        """
        if type(devices) is not list:
            devices = [devices]

        for device in devices:
            if not self._devices_list[device]["currentDevice"]:
                del self._devices_list[device]
                logger.info(u"User: {0} {1} - Removing device: {2}".format(self._name, self._surname, device))
            else:
                raise AttributeError((u"User: {0} {1} - Can't remove {2} It is set as current device".format(self._name, self._surname, device)))
Example #21
0
    def set_role_for_zone(self, zone_id, role):
        """
        Sets 'role' of user in given zone for current instance of User class
        :param zone_id: string - zone identifier
        :param role: UserRole - value of user's 'role'
        :return:
        """
        if type(role) is UserRole:
            raise TypeError(u"User: {0} {1} - Parameter 'role' can be only type enum UserRole".format(self._name, self._surname))

        for zone in self._zones:
            if zone['zoneId'] == zone_id:
                zone['role'] = role.name
                logger.info(u"User: {0} {1} - Role in zone: {2} set to: {3}".format(self._name, self._surname, zone_id, role.name))
Example #22
0
    def set_primary_zone_role(self, role):
        """
        Sets user's primary zone role
        :param role: UserRole - value of user's 'role'
        """
        if type(role) is not UserRole:
            raise TypeError(u"User: {0} {1} - Parameter 'role' can be only type enum UserRole".format(self._name, self._surname))

        for zone in self._zones:
            if zone['type'] == 'primary':
                zone['role'] = role.name
                logger.info(u"User: {0} {1} - Role in primary zone set to: {2}".format(self._name, self._surname, role.name))
                return

        raise TypeError(u"Primary zone was not found!")
Example #23
0
 def set_current_device(self, current_device):
     """
     Sets 'device' as 'current_device' in this instance of class User
     :param current_device: - desired device to be set as 'current_device' (enum type of AndroidDeviceType or IosDeviceType required)
     """
     if type(current_device) is AndroidDeviceType or type(current_device) is IosDeviceType:
         if current_device in self._devices_list:
             self._current_device = current_device
             for device in self._devices_list:
                 if device == current_device:
                     self._devices_list[device]["currentDevice"] = True
                 else:
                     self._devices_list[device]["currentDevice"] = False
             logger.info(u"User: {0} {1} - Current Device: {2}".format(self._name, self._surname, self._current_device))
         else:
             raise KeyError(u"User: {0} {1} - Setting Current device failed. {2} is not amongst devices in devices list".format(self._name, self._surname, current_device))
     else:
         raise TypeError(u"User: {0} {1} - Setting Current device failed. Parameter accepts only single AndroidDeviceType or IosDeviceType item".format(self._name, self._surname))
Example #24
0
    def set_primary_zone(self, role, zone_id):
        """
        Sets user's primary zone role and zoneId. Update existing primary zone or create new one.
        :param role: UserRole - value of user's 'role'
        :param zone_id: string - value of 'zone id' obtained from Cloud
        """
        if type(role) is not UserRole:
            raise TypeError(u"User: {0} {1} - Parameter 'role' can be only type enum UserRole".format(self._name, self._surname))

        for zone in self._zones:
            if zone['type'] == 'primary':
                zone['role'] = role.name
                zone['zoneId'] = zone_id
                logger.info(u"User: {0} {1} - updated primary zone (role:{2}, zoneId:{3})".format(self._name, self._surname, role.name, zone_id))
                return

        self._zones.append({'type': 'primary', 'role': role, 'zoneId': zone_id})
        logger.info(u"User: {0} {1} - set primary zone (role:{2}, zoneId:{3})".format(self._name, self._surname, role.name, zone_id))
def family_member_location_correct_address_is_displayed_on_card(params):
    latitude_value = InputParameterConvertor.convert_to_float(
        params['latitude_value'])
    longitude_value = InputParameterConvertor.convert_to_float(
        params['longitude_value'])
    accuracy_value = InputParameterConvertor.convert_to_int(
        params['accuracy_value'])

    if abs(latitude_value) > 90:
        execution.error("Wrong latitude: {}".format(latitude_value))

    if abs(longitude_value) > 180:
        execution.error("Wrong longitude: {}".format(longitude_value))

    if accuracy_value < 0:
        execution.error("Negative accuracy: {}".format(accuracy_value))

    location = {
        "latitude": latitude_value,
        "longitude": longitude_value,
        "accuracy": accuracy_value
    }
    address_from_google_api = LocationToAddress.location_to_address(location)

    user = variables.users[params['user']]
    label_to_search = user.get_name()
    if label_to_search == variables.logged_user.values()[0].get_name():
        label_to_search = "Me"

    user_plugin_status = variables.dashboard_screen.get_plugin_status_object_at_index_for_user_name(
        user_name=label_to_search, plugin_index=1)
    address_from_cell = user_plugin_status.get_text()

    diff = compare_values(address_from_cell, address_from_google_api)
    if diff:
        execution.error(
            "Address of user {0} is not displayed correctly.\n{1}".format(
                params['user'], diff))

    logger.info("Address of user {0} is displayed correctly.".format(
        params['user']))
    execution.passed()
def family_member_location_register_listener_for_packages(params):
    # path to web server
    server_path = "http://ddtfstorage-sn.cz.avg.com/Zaap/regression_tests/services/"

    # list of available packages
    available_packages = [
        "servicePackage.zip", "servicePackageNew.zip", "pluginDetail.zip",
        "fakeService1.zip", "fakeService2.zip", "fakeService3.zip",
        "fakeService1New.zip", "fakeService2New.zip", "fakeService3New.zip"
    ]

    # create list of packages from step parameter
    packages_list = params["packages_names_comma_separated"].split(",")
    packages_list = map(unicode.strip, packages_list)

    # check name validity of packages
    request_response = []
    for package in packages_list:
        package_checked = InputParameterConvertor.check_valid_parameter(
            input_data=package, valid_values_set=available_packages)
        resource_registration_request = ZprSimulatorSFCResourceStatus.create_message(
            package_checked)
        resource_registration_response = ZprSimulatorSFCResourceStatusResponse.create_message(
            True, "{0}{1}".format(server_path, package_checked))
        request_response.append(
            [resource_registration_request, resource_registration_response])

    registration_command = RegisterRequestListener.create_command(
        message_id="zpr.Simulator.SFC.ResourceStatus",
        request_response_list=request_response)

    check_command = variables.sim.send(registration_command)
    variables.sim.check_ack(check_command)
    logger.info(
        "Registration of package listener with message zpr.Simulator.SFC.ResourceStatus was successful."
    )

    execution.passed()
Example #27
0
    def __custom_android_clear_password(self):
        """
        Clear password input field and make sure it is cleared, this method also checks that deletion was successful
        """
        key_del = 67  # Key code for Backspace key

        self.edit_text_password.clear()

        try:
            AppiumObject(
                self.driver,
                "//*[@class='android.widget.EditText'][@password='******']",
                SelectorType.xpath).get_element()
            self.edit_text_password.click()
            self.button_show_password.click()

        except LookupError:
            logger.info("Password is displayed.")

        while self.edit_text_password.get_text() != self.PASSWORD_PLACEHOLDER:
            variables.driver.press_keycode(key_del)

        logger.info("Password should be gone as a spring snow :)")
        self.button_show_password.click()
Example #28
0
    def set_devices(self, devices):
        """
        Sets 'device' to the 'devices_list' currently held in this instance of class User (first device in dict set as new current device)
        :param devices: - desired device or list of devices to be set to 'devices_list' (enum type of AndroidDeviceType or IosDeviceType required)
        """
        self._devices_list = self._get_devices_info_from_files(self._process_input_device_type(devices))
        logger.info(u"User: {0} {1} - List of devices discarded".format(self._name, self._surname))

        for device in self._devices_list:
            logger.info(u"User: {0} {1} - Adding device: {2}".format(self._name, self._surname, device))

        # Update all devices with current account_id
        self._set_account_id_in_device_info(self._account_id)

        logger.info(u"User: {0} {1} - New list of devices is set")
Example #29
0
    def _airplane_mode_turn_off(self):
        if InputParameterConvertor.convert_to_int(
                self._button_airplane_mode.get_attribute('value')) == 0:
            logger.warning(
                "Trying to turn Airplane Mode OFF, but Airplane Mode is already OFF!"
            )
        else:
            self._button_airplane_mode.click()
            if not self._auto_accept_alerts:
                try:  # no SIM card > alert displayed > dismiss
                    self._missing_sim_card_alert.wait_for(10)
                    self._driver.switch_to.alert.accept()
                    logger.info("\"No SIM Card Installed\" alert dismissed.")
                except AssertionError:  # SIM card present > no alert displayed > no action taken
                    logger.info(
                        "\"No SIM Card Installed\" alert not detected, the test is running on a device with SIM card installed, or there was an error dismissing alert."
                    )

        logger.info("Airplane Mode state: OFF")
def family_member_location_correct_address_timestamp_displayed_on_card(params):
    element_name = InputParameterConvertor.check_valid_parameter(
        params['element_name'].upper(), ["ADDRESS", "TIMESTAMP"])
    option_name = InputParameterConvertor.check_valid_parameter(
        params['option_name'], [
            "Address level", "Street level", "Post code level", "Town level",
            "Safe place", "Offline", "Invisible", "Just now", "5m ago",
            "10m ago", "59m ago", "2h ago", "23h ago", "1d ago", "2d ago"
        ])
    if option_name in ("Safe place", "Offline", "Invisible"):
        execution.error(
            "Address checking for device status Safe place, Offline and Invisible will be implemented later."
        )

    user = variables.users[params['user_name']]
    label_to_search = user.get_name()
    if label_to_search == variables.logged_user.values()[0].get_name():
        label_to_search = "Me"

    if element_name == 'ADDRESS':
        logger.info("Getting ADDRESS from plugin card for user: {0}".format(
            user.get_name()))
        plugin_status = variables.dashboard_screen.get_plugin_status_object_at_index_for_user_name(
            user_name=label_to_search, plugin_index=1)
        address_from_cell = plugin_status.get_text()
        logger.info(u"ADDRESS: {0}".format(address_from_cell))

        accuracy = {
            "Address level": 5,
            "Street level": 358,
            "Post code level": 30000,
            "Town level": 40000
        }[option_name]
        location = variables.locations_of_users[user.get_account_id(
        )]['data']  # for each user there are two files saved: 'data' (contains location data) and 'deviceId'
        location["accuracy"] = accuracy
        address_from_google_api = LocationToAddress.location_to_address(
            location)

        diff = compare_values(address_from_cell, address_from_google_api)
        if diff:
            execution.error(
                "Address with accuracy: {0} for user {1} is not displayed correctly!\n{2}"
                .format(option_name, user.get_name(), diff))

    elif element_name == 'TIMESTAMP':
        logger.info("Getting TIMESTAMP from plugin card for user: {0}".format(
            user.get_name()))
        plugin_detail = variables.dashboard_screen.get_plugin_detail_object_at_index_for_user_name(
            user_name=label_to_search, plugin_index=1)
        time_label_from_cell = plugin_detail.get_text()
        logger.info(u"TIMESTAMP: {0}".format(time_label_from_cell))

        if option_name == "Just now":
            if time_label_from_cell not in ["Just now", "1 min"]:
                execution.error(
                    "Timestamp with time: Just now for user {0} is not displayed correctly!\nDisplayed: {1}, expected: 'Just now' or '1 min'!"
                    .format(user.get_name(), time_label_from_cell))
        elif option_name in ("5m ago", "10m ago", "59m ago", "2h ago",
                             "23h ago", "1d ago", "2d ago"):
            diff = None
            if is_android():
                timestamp_check = TimeConverter.check_timestamp(
                    time_label_from_cell, 60)
                diff = timestamp_check['error_message']
            elif is_ios():
                delta = option_name.split(' ')[0]
                time_label_from_python = TimeConverter.ios_localized_timestamp_for_saved_time_at_creation(
                    delta, format24h=True)
                diff = compare_values(time_label_from_cell,
                                      time_label_from_python)
            else:
                execution.error("Specified OS is not supported/implemented")

            if diff:
                execution.error(
                    "Timestamp for user {0} is not displayed correctly!\n{1}".
                    format(user.get_name(), diff))
        else:
            execution.error(
                "Timestamp can not have value {0}! Please check step parameters."
                .format(option_name))

    logger.info("{0} of user {1} is displayed correctly.".format(
        element_name, user.get_name()))
    execution.passed()