Пример #1
0
def get_test_modules(arguments):
    """
     This function loads the all modules in the tests directory into testing
     environment.

    :param arguments: this is command line arguments for module name to
    which test suite will run
    :type arguments: dict
    :return module list: test module list
    :rtype: list
    """

    from pgadmin.utils.route import TestsGeneratorRegistry

    exclude_pkgs = []
    global driver, app_starter, handle_cleanup

    if not config.SERVER_MODE:
        # following test cases applicable only for server mode
        exclude_pkgs.extend([
            "browser.tests.test_change_password",
            "browser.tests.test_gravatar_image_display",
            "browser.tests.test_login",
            "browser.tests.test_logout",
            "browser.tests.test_reset_password",
            "browser.tests.test_ldap_login",
            "browser.tests.test_ldap_with_mocking",
        ])
    if arguments['exclude'] is not None:
        exclude_pkgs += arguments['exclude'].split(',')

    if 'feature_tests' not in exclude_pkgs and \
        (arguments['pkg'] is None or arguments['pkg'] == "all" or
         arguments['pkg'] == "feature_tests"):

        if arguments['pkg'] == "feature_tests":
            exclude_pkgs.extend(['resql'])

        if not test_utils.is_parallel_ui_tests(args):
            driver = setup_webdriver_specification(arguments)
            app_starter = AppStarter(driver, config)
            app_starter.start_app()

    handle_cleanup = test_utils.get_cleanup_handler(test_client, app_starter)
    # Register cleanup function to cleanup on exit
    atexit.register(handle_cleanup)

    # Load Test modules
    module_list = load_modules(arguments, exclude_pkgs)
    return module_list
Пример #2
0
    try:
        test_module_list = get_test_modules(args)
    except Exception as e:
        print(str(e))
        sys.exit(1)
    # Login the test client
    test_utils.login_tester_account(test_client)

    servers_info = test_utils.get_config_data()
    node_name = "all"
    if args['pkg'] is not None:
        node_name = args['pkg'].split('.')[-1]

    # Check if feature tests included & parallel tests switch passed
    if test_utils.is_feature_test_included(args) and \
            test_utils.is_parallel_ui_tests(args):
        try:
            # Get selenium config dict
            selenoid_config = test_setup.config_data['selenoid_config']

            # Set DEFAULT_SERVER value
            default_server = selenoid_config['pgAdmin_default_server']
            os.environ["PGADMIN_CONFIG_DEFAULT_SERVER"] = str(default_server)
            config.DEFAULT_SERVER = str(default_server)

            # Get hub url
            hub_url = selenoid_config['selenoid_url']

            # Get selenium grid status & list of available browser out passed
            selenium_grid_status, list_of_browsers \
                = test_utils.get_selenium_grid_status_and_browser_list(hub_url,
Пример #3
0
def get_test_modules(arguments):
    """
     This function loads the all modules in the tests directory into testing
     environment.

    :param arguments: this is command line arguments for module name to
    which test suite will run
    :type arguments: dict
    :return module list: test module list
    :rtype: list
    """

    from pgadmin.utils.route import TestsGeneratorRegistry

    exclude_pkgs = []
    global driver, app_starter, handle_cleanup

    if not config.SERVER_MODE:
        # following test cases applicable only for server mode
        exclude_pkgs.extend([
            "browser.tests.test_change_password",
            "browser.tests.test_gravatar_image_display",
            "browser.tests.test_login",
            "browser.tests.test_logout",
            "browser.tests.test_reset_password",
            "browser.tests.test_ldap_login",
            "browser.tests.test_ldap_with_mocking",
        ])
    if arguments['exclude'] is not None:
        exclude_pkgs += arguments['exclude'].split(',')

    if 'feature_tests' not in exclude_pkgs and \
        (arguments['pkg'] is None or arguments['pkg'] == "all" or
         arguments['pkg'] == "feature_tests"):

        if arguments['pkg'] == "feature_tests":
            exclude_pkgs.extend(['resql'])

        if not test_utils.is_parallel_ui_tests(args):
            from selenium import webdriver
            from selenium.webdriver.chrome.options import Options
            from selenium.webdriver.common.desired_capabilities import \
                DesiredCapabilities

            default_browser = 'chrome'

            # Check default browser provided through command line. If provided
            # then use that browser as default browser else check for the
            # setting provided in test_config.json file.
            if ('default_browser' in arguments
                    and arguments['default_browser'] is not None):
                default_browser = arguments['default_browser'].lower()
            elif (test_setup.config_data
                  and "default_browser" in test_setup.config_data):
                default_browser = test_setup.config_data[
                    'default_browser'].lower()

            if default_browser == 'firefox':
                cap = DesiredCapabilities.FIREFOX
                cap['requireWindowFocus'] = True
                cap['enablePersistentHover'] = False
                profile = webdriver.FirefoxProfile()
                profile.set_preference("dom.disable_beforeunload", True)
                driver = webdriver.Firefox(capabilities=cap,
                                           firefox_profile=profile)
                driver.implicitly_wait(1)
            else:
                options = Options()
                if test_setup.config_data and \
                    'headless_chrome' in test_setup.config_data and \
                        test_setup.config_data['headless_chrome']:
                    options.add_argument("--headless")
                options.add_argument("--no-sandbox")
                options.add_argument("--disable-setuid-sandbox")
                options.add_argument("--window-size=1280,1024")
                options.add_argument("--disable-infobars")
                options.add_experimental_option('w3c', False)
                driver = webdriver.Chrome(chrome_options=options)

            # maximize browser window
            driver.maximize_window()

            app_starter = AppStarter(driver, config)
            app_starter.start_app()

    handle_cleanup = test_utils.get_cleanup_handler(test_client, app_starter)
    # Register cleanup function to cleanup on exit
    atexit.register(handle_cleanup)

    # Load the test modules which are in given package(i.e. in arguments.pkg)
    if arguments['pkg'] is None or arguments['pkg'] == "all":
        TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs)
    elif arguments['pkg'] is not None and arguments['pkg'] == "resql":
        for_modules = []
        if arguments['modules'] is not None:
            for_modules = arguments['modules'].split(',')

        # Load the reverse engineering sql test module
        TestsGeneratorRegistry.load_generators('pgadmin',
                                               exclude_pkgs,
                                               for_modules,
                                               is_resql_only=True)
    else:
        for_modules = []
        if arguments['modules'] is not None:
            for_modules = arguments['modules'].split(',')

        TestsGeneratorRegistry.load_generators('pgadmin.%s' % arguments['pkg'],
                                               exclude_pkgs, for_modules)

    # Sort module list so that test suite executes the test cases sequentially
    module_list = TestsGeneratorRegistry.registry.items()
    module_list = sorted(module_list, key=lambda module_tuple: module_tuple[0])
    return module_list