Exemplo n.º 1
0
def open_about_firefox():
    """Open the 'About Firefox' window."""
    if OSHelper.get_os() == OSPlatform.MAC:
        type(Key.F3, modifier=KeyModifier.CTRL)
        type(Key.F2, modifier=KeyModifier.CTRL)

        time.sleep(0.5)
        type(Key.RIGHT)
        type(Key.DOWN)
        type(Key.DOWN)
        type(Key.ENTER)

    elif OSHelper.get_os() == OSPlatform.WINDOWS:
        type(Key.ALT)
        if args.locale != 'ar':
            type(Key.LEFT)
        else:
            type(Key.RIGHT)
        type(Key.ENTER)
        type(Key.UP)
        type(Key.ENTER)

    else:
        type(Key.F10)
        if args.locale != 'ar':
            type(Key.LEFT)
        else:
            type(Key.RIGHT)
        type(Key.UP)
        type(Key.ENTER)
Exemplo n.º 2
0
def is_blocked(bug_id):
    """Checks if a Github issue/Bugzilla bug is blocked or not."""
    try:
        if 'issue_' in bug_id:
            bug = get_github_issue(bug_id)
            if bug is None:
                return True
            if bug.state == 'closed':
                return False
            else:
                if OSHelper.get_os() in bug.title:
                    return True
                return False
        else:
            bug = get_bugzilla_bug(bug_id)
            if bug is None:
                return True
            if bug.status in ['CLOSED', 'RESOLVED']:
                return False
            else:
                if bugzilla_os[OSHelper.get_os().
                               value] == bug.op_sys or bug.platform in [
                                   'All', 'Unspecified'
                               ]:
                    return True
                return False
    except BugManagerError as e:
        logger.error(str(e))
        return True
Exemplo n.º 3
0
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)

        if OSHelper.is_mac():
            mouse_reset()
        if item.name == 'test_run':
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = 'enabled' in values and not values.get(
                'enabled') and not core_args.override
            is_excluded = 'exclude' in values and OSHelper.get_os(
            ) in values.get('exclude')
            incorrect_locale = 'locale' in values and core_args.locale not in values.get(
                'locale')
            incorrect_platform = 'platform' in values and OSHelper.get_os(
            ) not in values.get('platform')
            fx_version = self.values.get('fx_version')
            incorrect_fx_version = 'fx_version' in values and not check_version(
                fx_version, values.get('fx_version'))

            if is_disabled:
                skip_reason_list.append('Test is disabled')

            if is_excluded:
                skip_reason_list.append('Test is excluded for {}'.format(
                    OSHelper.get_os()))

            if 'blocked_by' in values:
                bug_id = values.get('blocked_by')
                if is_blocked(bug_id):
                    skip_reason_list.append(
                        'Test is blocked by [{}]'.format(bug_id))

            if incorrect_locale:
                skip_reason_list.append(
                    'Test doesn\'t support locale [{}]'.format(
                        core_args.locale))

            if incorrect_platform:
                skip_reason_list.append(
                    'Test doesn\'t support platform [{}]'.format(
                        OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append(
                    'Test doesn\'t support Firefox version [{}]'.format(
                        fx_version))

            if len(skip_reason_list) > 0:
                logger.info('Test skipped: - [{}]: {} Reason(s): {}'.format(
                    item.nodeid.split(':')[0], values.get('description'),
                    ', '.join(skip_reason_list)))
                test_instance = (item, 'SKIPPED', None)

                test_result = create_result_object(test_instance, 0, 0)
                self.completed_tests.append(test_result)
                pytest.skip(item)
Exemplo n.º 4
0
    def get_local_firefox_path() -> str or None:
        """Checks if Firefox is installed on your machine."""
        paths = {
            'osx': [
                '/Applications/Firefox.app/Contents/MacOS/firefox',
                '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox',
                '/Applications/Firefox Nightly.app/Contents/MacOS/firefox'
            ],
            'win': [
                'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
                'C:\\Program Files (x86)\\Firefox Developer Edition\\firefox.exe',
                'C:\\Program Files (x86)\\Nightly\\firefox.exe',
                'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
                'C:\\Program Files\\Firefox Developer Edition\\firefox.exe',
                'C:\\Program Files\\Nightly\\firefox.exe'
            ],
            'linux': ['/usr/bin/firefox', '/usr/lib/firefox/firefox']
        }
        if OSHelper.is_windows():
            paths['win'].append(PathManager.get_win_environment_path())

        for path in paths[OSHelper.get_os().value]:
            if os.path.exists(path):
                return path
        return None
Exemplo n.º 5
0
 def __init__(self, app, total_tests_run, passed_tests, failed_tests, skipped_tests, errors, total_time, failures):
     self.platform = OSHelper.get_os().value
     self.app = app
     self.total_tests_run = total_tests_run
     self.failed_tests = failed_tests
     self.passed_tests = passed_tests
     self.skipped_tests = skipped_tests
     self.error_tests = errors
     self.total_duration = total_time
     self.failures = failures
Exemplo n.º 6
0
    def generate_test_plan_name(firefox_version: str):
        """
        :param firefox_version: actual version of Firefox
        :return: name of the test plan

        name of the test run is generated based on the OS , date and build number
        this method can be be improved to add more details
        """
        test_plan_name = '[Firefox %s][%s]Iris Test Run %s' % (
            firefox_version, OSHelper.get_os().capitalize(), date.today())

        logger.debug('Creating Test Plan', test_plan_name)
        return test_plan_name
Exemplo n.º 7
0
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)

        if OSHelper.is_mac():
            mouse_reset()
        if item.name == 'run' and not core_args.override:
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = 'enabled' in values and not values.get('enabled') and not core_args.override
            is_excluded = 'exclude' in values and OSHelper.get_os() in values.get('exclude')
            incorrect_locale = 'locale' in values and core_args.locale not in values.get('locale')
            incorrect_platform = 'platform' in values and OSHelper.get_os() not in values.get('platform')
            fx_version = self.values.get('fx_version')
            incorrect_fx_version = 'fx_version' in values and not check_version(fx_version, values.get('fx_version'))

            if is_disabled:
                skip_reason_list.append('Test is disabled')

            if is_excluded:
                skip_reason_list.append('Test is excluded for {}'.format(OSHelper.get_os()))

            if 'blocked_by' in values:
                bug_id = ''
                platform = OSHelper.get_os()
                if type(values.get('blocked_by')) is str:
                    bug_id = values.get('blocked_by')
                elif type(values.get('blocked_by')) is dict:
                    try:
                        bug_id = values.get('blocked_by')['id']
                        platform = values.get('blocked_by')['platform']
                    except KeyError as e:
                        logger.debug('Missing key in blocked_by field: %s' % e)
                logger.debug('Looking up bug #%s...' % bug_id)
                blocked_platform = OSHelper.get_os() in platform
                logger.debug('Test has blocking issue: %s' % is_blocked(bug_id))
                logger.debug('Test is blocked on this platform: %s' % blocked_platform)
                if is_blocked(bug_id) and blocked_platform:
                    skip_reason_list.append('Test is blocked by [{}] on this platform.'.format(bug_id))

            if incorrect_locale:
                skip_reason_list.append('Test doesn\'t support locale [{}]'.format(core_args.locale))

            if incorrect_platform:
                skip_reason_list.append('Test doesn\'t support platform [{}]'.format(OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append('Test doesn\'t support Firefox version [{}]'.format(fx_version))

            if len(skip_reason_list) > 0:
                logger.info(
                    'Test skipped: - [{}]: {} Reason(s): {}'.format(item.nodeid.split(':')[0],
                                                                    values.get('description'),
                                                                    ', '.join(skip_reason_list)))
                test_instance = (item, 'SKIPPED', None)

                test_result = create_result_object(test_instance, 0, 0)
                self.completed_tests.append(test_result)
                pytest.skip(item)
Exemplo n.º 8
0
def select_location_bar_option(option_number):
    """Select option from the location bar menu.

    :param option_number: Option number.
    :return: None.
    """
    if OSHelper.get_os() == OSPlatform.WINDOWS:
        for i in range(option_number + 1):
            type(Key.DOWN)
        type(Key.ENTER)
    else:
        for i in range(option_number - 1):
            type(Key.DOWN)
        type(Key.ENTER)
Exemplo n.º 9
0
def get_rule_for_channel(channel, current_version):
    """
    :param channel: Firefox channel.
    :param current_version: Current Firefox version.
    :return: Channel's list of rules.
    """
    rules = get_update_rules()
    if rules is None:
        return None

    result_list = [x for x in rules if x['channel'] == channel and OSHelper.get_os() in x['os'] and
                   check_version(current_version, x['starting_condition'])]
    if len(result_list) == 0:
        return None
    elif len(result_list) > 1:
        logger.warning('Multiple rules for \'{}\' channel'.format(channel))
        return result_list[0]
    return result_list[0]
Exemplo n.º 10
0
def create_run_log(app):
    args = get_core_args()
    meta = {
        'run_id':
        PathManager.get_run_id(),
        'platform':
        OSHelper.get_os().value,
        'config':
        '%s, %s-bit, %s' % (OSHelper.get_os().value, OSHelper.get_os_bits(),
                            OSHelper.get_processor()),
        'locale':
        args.locale,
        'args':
        ' '.join(sys.argv),
        'params':
        vars(args),
        'log':
        os.path.join(PathManager.get_current_run_dir(), 'iris_log.log')
    }
    values = {}
    for i in app.values:
        values[i] = app.values[i]
    meta['values'] = values

    repo = git.Repo(PathManager.get_module_dir())
    meta['iris_version'] = 2.0
    meta['iris_repo'] = repo.working_tree_dir
    meta['iris_branch'] = repo.active_branch.name
    meta['iris_branch_head'] = repo.head.object.hexsha
    meta['python_version'] = get_python_version()

    failed = 0
    passed = 0
    skipped = 0
    errors = 0

    for test in app.completed_tests:
        if test.outcome == 'FAILED':
            failed = failed + 1
        if test.outcome == 'PASSED':
            passed = passed + 1
        if test.outcome == 'SKIPPED':
            skipped = skipped + 1
        if test.outcome == 'ERROR':
            errors = errors + 1

    logger.debug('Updating runs.json with completed run data.')
    meta['total'] = len(app.completed_tests)
    meta['passed'] = passed
    meta['failed'] = failed
    meta['skipped'] = skipped
    meta['errors'] = errors
    meta['start_time'] = app.start_time
    meta['end_time'] = app.end_time
    meta['total_time'] = app.end_time - app.start_time

    tests = {
        'all_tests': convert_test_list(app.completed_tests),
        'failed_tests': convert_test_list(app.completed_tests,
                                          only_failures=True)
    }

    run_file = os.path.join(PathManager.get_current_run_dir(), 'run.json')
    run_file_data = {'meta': meta, 'tests': tests}

    with open(run_file, 'w') as f:
        json.dump(run_file_data, f, sort_keys=True, indent=True)
Exemplo n.º 11
0
 def get_images_path():
     """Returns images directory path."""
     return os.path.join('images', OSHelper.get_os().value)
Exemplo n.º 12
0
def _get_image_path(caller, image: str, target: str) -> str:
    """Enforce proper location for all Pattern creation.

    :param caller: Path of calling Python module.
    :param image: String filename of image.
    :return: Full path to image on disk.

    We will look at all possible paths relative to the calling file, with this priority:

    - current platform locale folder
    - common locale folder
    - current platform root
    - common root

    Each directory is scanned for four possible file names, depending on resolution.
    If the above fails, we will look up the file name in the list of project-wide images,
    and return whatever we find, with a warning message.
    If we find nothing, we will raise an exception.
    """

    module = os.path.split(caller)[1]
    module_directory = os.path.split(caller)[0]
    parent_directory = os.path.basename(module_directory)
    file_name = image.split('.')[0]
    names = [image, '*****@*****.**' % file_name]

    if OSHelper.get_os_version() == 'win7':
        os_version = 'win7'
    else:
        os_version = OSHelper.get_os().value
    paths = []
    current_locale = ''
    try:
        current_locale = get_core_args().locale
    except AttributeError:
        pass

    platform_directory = os.path.join(module_directory, 'images', os_version)
    platform_locale_directory = os.path.join(platform_directory,
                                             current_locale)
    for name in names:
        paths.append(os.path.join(platform_locale_directory, name))

    common_directory = os.path.join(module_directory, 'images', 'common')
    common_locale_directory = os.path.join(common_directory, current_locale)
    for name in names:
        paths.append(os.path.join(common_locale_directory, name))

    for name in names:
        paths.append(os.path.join(platform_directory, name))

    for name in names:
        paths.append(os.path.join(common_directory, name))

    found = False
    image_path = None
    for path in paths:
        if os.path.exists(path):
            found = True
            image_path = path
            break

    if found:
        logger.debug('Module %s requests image %s' % (module, image))
        logger.debug('Found %s' % image_path)
        return image_path
    else:
        result_list = [
            x for x in _load_all_patterns(target) if x['name'] == image
        ]
        if len(result_list) > 0:
            res = result_list[0]
            logger.warning(
                'Failed to find image %s in default locations for module %s.' %
                (image, module))
            logger.warning('Using this one instead: %s' % res['path'])
            logger.warning(
                'Please move image to correct location relative to caller.')
            location_1 = os.path.join(parent_directory, 'images', 'common')
            location_2 = os.path.join(parent_directory,
                                      PathManager.get_images_path())
            logger.warning('Suggested locations: %s, %s' %
                           (location_1, location_2))
            return res['path']
        else:
            logger.error('Pattern creation for %s failed for caller %s.' %
                         (image, caller))
            logger.error(
                'Image not found. Either it is in the wrong platform folder, or it does not exist.'
            )
            logger.debug('Paths searched:')
            logger.debug('\n'.join(paths))
            raise FindError('Pattern not found.')
Exemplo n.º 13
0
 class Organize(object):
     NEW_BOOKMARK = Pattern('newbookmark.png')
     NEW_FOLDER = Pattern('newfolder.png')
     NEW_SEPARATOR = Pattern('newseparator.png')
     if OSHelper.get_os() != OSPlatform.MAC:
         CLOSE = Pattern('orgClose.png')