Esempio n. 1
0
    def initialize_config_files(tc_config_files=None):
        """Initialize config files and update config files names with the environment

        :param tc_config_files: test case specific config files
        :returns: initialized config files object
        """
        # Initialize config files
        if tc_config_files is None:
            tc_config_files = ConfigFiles()

        # Update properties and log file names if an environment is configured
        env = DriverWrappersPool.get_configured_value('Config_environment', None, None)
        if env:
            # Update config properties filenames
            prop_filenames = tc_config_files.config_properties_filenames
            new_prop_filenames_list = prop_filenames.split(';') if prop_filenames else ['properties.cfg']
            base, ext = os.path.splitext(new_prop_filenames_list[0])
            new_prop_filenames_list.append('{}-{}{}'.format(env, base, ext))
            new_prop_filenames_list.append('local-{}-{}{}'.format(env, base, ext))
            tc_config_files.set_config_properties_filenames(*new_prop_filenames_list)

            # Update output log filename
            output_log_filename = tc_config_files.output_log_filename
            base, ext = os.path.splitext(output_log_filename) if output_log_filename else ('toolium', '.log')
            tc_config_files.set_output_log_filename('{}_{}{}'.format(base, env, ext))

        return tc_config_files
Esempio n. 2
0
def driver_wrapper():
    # Configure properties
    config_files = ConfigFiles()
    root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_config_properties_filenames('properties.cfg')
    driver_wrapper = DriverWrappersPool.get_default_wrapper()
    driver_wrapper.configure(config_files)

    return driver_wrapper
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()

        # Create default wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()

        # Configure properties
        config_files = ConfigFiles()
        root_path = os.path.dirname(os.path.realpath(__file__))
        config_files.set_config_directory(os.path.join(root_path, 'conf'))
        config_files.set_output_directory(os.path.join(root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)
Esempio n. 4
0
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()

        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_output_directory(os.path.join(self.root_path, 'output'))
        DriverWrappersPool.configure_common_directories(config_files)
        self.driver_wrapper.configure_properties()
Esempio n. 5
0
def driver_wrapper():
    # Remove previous visual path
    root_path = os.path.dirname(os.path.realpath(__file__))
    visual_path = os.path.join(root_path, 'output', 'visualtests')
    if os.path.exists(visual_path):
        shutil.rmtree(visual_path)

    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    driver_wrapper = DriverWrappersPool.get_default_wrapper()
    driver_wrapper.driver = mock.MagicMock()

    # Configure properties
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files = ConfigFiles()
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_config_properties_filenames('properties.cfg')
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    driver_wrapper.configure(config_files)
    driver_wrapper.config.set('VisualTests', 'enabled', 'true')

    yield driver_wrapper

    # Remove visual path
    visual_path = os.path.join(root_path, 'output', 'visualtests')
    if os.path.exists(visual_path):
        shutil.rmtree(visual_path)

    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None
Esempio n. 6
0
def driver_wrapper():
    """Create a new mock element and a new driver before each test"""
    global mock_element
    mock_element = mock.MagicMock(spec=WebElement)
    mock_element.find_element.return_value = child_element

    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    driver_wrapper = DriverWrappersPool.get_default_wrapper()

    # Configure wrapper
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files = ConfigFiles()
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    config_files.set_config_log_filename('logging.conf')
    DriverWrappersPool.configure_common_directories(config_files)
    driver_wrapper.configure_properties()

    driver_wrapper.driver = mock.MagicMock()
    driver_wrapper.is_mobile_test = mock.MagicMock(return_value=False)

    return driver_wrapper
Esempio n. 7
0
    def setUp(self):
        # Remove previous visual path
        visual_path = os.path.join(self.root_path, 'output', 'visualtests')
        if os.path.exists(visual_path):
            shutil.rmtree(visual_path)

        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
        self.driver_wrapper.driver = mock.MagicMock()

        # Configure properties
        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_config_properties_filenames('properties.cfg')
        config_files.set_output_directory(
            os.path.join(self.root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)
        self.driver_wrapper.config.set('VisualTests', 'enabled', 'true')

        # Create a new VisualTest instance
        self.visual = VisualTest(self.driver_wrapper)
Esempio n. 8
0
def driver_wrapper():
    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    new_driver_wrapper = DriverWrappersPool.get_default_wrapper()

    # Configure wrapper
    config_files = ConfigFiles()
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    config_files.set_config_log_filename('logging.conf')
    new_driver_wrapper.configure(config_files)

    yield new_driver_wrapper

    # Remove used environment properties after test
    global environment_properties
    for env_property in environment_properties:
        try:
            del os.environ[env_property]
        except KeyError:
            pass
    environment_properties = []
Esempio n. 9
0
def before_all(context):
    """Initialization method that will be executed before the test execution

    :param context: behave context
    """
    # Use pytest asserts if behave_pytest is installed
    install_pytest_asserts()

    if not hasattr(context, 'config_files'):
        context.config_files = ConfigFiles()

    # By default config directory is located in environment path
    if not context.config_files.config_directory:
        context.config_files.set_config_directory(
            DriverWrappersPool.get_default_config_directory())

    # Get 'Config_environment' property from user input (e.g. -D Config_environment=ios)
    env = context.config.userdata.get('Config_environment')
    # Deprecated: Get 'env' property from user input (e.g. -D env=ios)
    env = env if env else context.config.userdata.get('env')
    if env:
        os.environ['Config_environment'] = env

    context.global_status = {'test_passed': True}
    create_and_configure_wrapper(context)
Esempio n. 10
0
def before_all(context):
    """Initialization method that will be executed before the test execution

    :param context: behave context
    """
    # Use pytest asserts if behave_pytest is installed
    install_pytest_asserts()

    # Get 'TOOLIUM_CONFIG_ENVIRONMENT' property from user input (e.g. -D TOOLIUM_CONFIG_ENVIRONMENT=ios)
    env = context.config.userdata.get('TOOLIUM_CONFIG_ENVIRONMENT')
    # Deprecated: use TOOLIUM_CONFIG_ENVIRONMENT property
    env = env if env else context.config.userdata.get('Config_environment')
    # Deprecated: use TOOLIUM_CONFIG_ENVIRONMENT property
    env = env if env else context.config.userdata.get('env')
    if env:
        os.environ['TOOLIUM_CONFIG_ENVIRONMENT'] = env

    if not hasattr(context, 'config_files'):
        context.config_files = ConfigFiles()
    context.config_files = DriverWrappersPool.initialize_config_files(
        context.config_files)

    # By default config directory is located in environment path
    if not context.config_files.config_directory:
        context.config_files.set_config_directory(
            DriverWrappersPool.get_default_config_directory())

    context.global_status = {'test_passed': True}
    create_and_configure_wrapper(context)

    # Behave dynamic environment
    context.dyn_env = DynamicEnvironment(logger=context.logger)
Esempio n. 11
0
 def test_empty_config_files(self):
     config_files = ConfigFiles()
     assert_is_none(config_files.config_directory)
     assert_is_none(config_files.output_directory)
     assert_is_none(config_files.config_properties_filenames)
     assert_is_none(config_files.config_log_filename)
     assert_is_none(config_files.output_log_filename)
def driver_wrapper():
    # Create a new wrapper
    new_driver_wrapper = DriverWrappersPool.get_default_wrapper()

    # Configure wrapper
    config_files = ConfigFiles()
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    DriverWrappersPool.configure_common_directories(config_files)

    yield new_driver_wrapper

    # Remove environment properties after test
    try:
        del os.environ["Config_log_filename"]
    except KeyError:
        pass
Esempio n. 13
0
class BasicTestCase(unittest.TestCase):
    """A class whose instances are api test cases."""
    config_files = ConfigFiles()
    driver_wrapper = None

    @classmethod
    def get_subclass_name(cls):
        return cls.__name__

    def get_method_name(self):
        # Split remove the test suffix added by ddt library
        return self._testMethodName.split('___')[0]

    def get_subclassmethod_name(self):
        return self.__class__.__name__ + "." + self.get_method_name()

    @classmethod
    def tearDownClass(cls):
        change_all_jira_status()

    def setUp(self):
        # Configure logger and properties
        if not isinstance(self, SeleniumTestCase):
            # By default config directory is located in test path
            if not self.config_files.config_directory:
                self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

            self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
            self.driver_wrapper.configure(False, self.config_files)
        # Get config and logger instances
        self.config = self.driver_wrapper.config
        self.logger = logging.getLogger(__name__)
        self.logger.info("Running new test: %s", self.get_subclassmethod_name())

    def tearDown(self):
        # Get unit test exception
        py2_exception = sys.exc_info()[1]
        try:
            # Python 3.4+
            exception_info = self._outcome.errors[-1][1] if len(self._outcome.errors) > 0 else None
            exception = exception_info[1] if exception_info else None
        except AttributeError:
            try:
                # Python 3.3
                exceptions_list = self._outcomeForDoCleanups.failures + self._outcomeForDoCleanups.errors
                exception = exceptions_list[0][1] if exceptions_list else None
            except AttributeError:
                # Python 2.7
                exception = py2_exception

        if not exception:
            self._test_passed = True
            self.logger.info("The test '%s' has passed", self.get_subclassmethod_name())
        else:
            self._test_passed = False
            error_message = get_error_message_from_exception(exception)
            self.logger.error("The test '%s' has failed: %s", self.get_subclassmethod_name(), error_message)
Esempio n. 14
0
def before_all(context):
    """Initialization method that will be executed before the test execution

    :param context: behave context
    """
    config_files = ConfigFiles()
    config_files.set_config_directory(os.path.join(get_root_path(), 'conf'))
    config_files.set_output_directory(os.path.join(get_root_path(), 'output'))
    config_files.set_config_properties_filenames('properties.cfg',
                                                 'local-properties.cfg')
    context.config_files = config_files
    toolium_before_all(context)
Esempio n. 15
0
def test_configure_no_changes(driver_wrapper):
    # Check previous values
    assert driver_wrapper.config.get('Driver', 'type') == 'firefox'

    # Modify wrapper
    driver_wrapper.config.set('Driver', 'type', 'opera')

    # Trying to configure again
    driver_wrapper.configure(ConfigFiles())

    # Configuration has not been initialized
    assert driver_wrapper.config.get('Driver', 'type') == 'opera'
Esempio n. 16
0
def test_configure_environment(driver_wrapper):
    # Check previous values
    assert driver_wrapper.config.get('Driver', 'type') == 'firefox'

    # Change environment and try to configure again
    os.environ["Config_environment"] = 'android'
    config_files = DriverWrappersPool.initialize_config_files(ConfigFiles())
    driver_wrapper.configure(config_files)
    del os.environ["Config_environment"]

    # Check that configuration has been initialized
    assert driver_wrapper.config.get('Driver', 'type') == 'android'
Esempio n. 17
0
def test_configure_environment_deprecated_property(driver_wrapper):
    # Check previous values
    assert driver_wrapper.config.get('Driver', 'type') == 'firefox'

    # Change environment and try to configure again
    environment_properties.append('Config_environment')
    os.environ['Config_environment'] = 'android'
    config_files = DriverWrappersPool.initialize_config_files(ConfigFiles())
    driver_wrapper.configure(config_files)

    # Check that configuration has been initialized
    assert driver_wrapper.config.get('Driver', 'type') == 'android'
Esempio n. 18
0
 def setUp(self):
     self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
     config_files = ConfigFiles()
     config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
     config_files.set_output_directory(
         os.path.join(self.root_path, 'output'))
     DriverWrappersPool.configure_common_directories(config_files)
Esempio n. 19
0
    def initialize_config_files(tc_config_files=None):
        """Initialize config files and update config files names with the environment

        :param tc_config_files: test case specific config files
        :returns: initialized config files object
        """
        # Initialize config files
        if tc_config_files is None:
            tc_config_files = ConfigFiles()

        # Update properties and log file names if an environment is configured
        env = DriverWrappersPool.get_configured_value('Config_environment',
                                                      None, None)
        if env:
            # Update config properties filenames
            prop_filenames = tc_config_files.config_properties_filenames
            new_prop_filenames_list = prop_filenames.split(
                ';') if prop_filenames else ['properties.cfg']
            base, ext = os.path.splitext(new_prop_filenames_list[0])
            new_prop_filenames_list.append('{}-{}{}'.format(env, base, ext))
            new_prop_filenames_list.append('local-{}-{}{}'.format(
                env, base, ext))
            tc_config_files.set_config_properties_filenames(
                *new_prop_filenames_list)

            # Update output log filename
            output_log_filename = tc_config_files.output_log_filename
            base, ext = os.path.splitext(
                output_log_filename) if output_log_filename else ('toolium',
                                                                  '.log')
            tc_config_files.set_output_log_filename('{}_{}{}'.format(
                base, env, ext))

        return tc_config_files
Esempio n. 20
0
def before_all(context):
    """Initialization method that will be executed before the test execution

    :param context: behave context
    """
    config_files = ConfigFiles()
    config_files.set_config_directory(os.path.join(get_root_path(), 'conf'))
    config_files.set_output_directory(os.path.join(get_root_path(), 'output'))
    config_files.set_config_properties_filenames('properties.cfg', 'local-properties.cfg')
    context.config_files = config_files
    toolium_before_all(context)
Esempio n. 21
0
def test_before_all(create_and_configure_wrapper):
    # Create context mock
    context = mock.MagicMock()
    context.config.userdata.get.return_value = None
    context.config_files = ConfigFiles()

    before_all(context)

    # Check that configuration folder is the same as environment folder
    expected_config_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'conf')
    assert context.config_files.config_directory == expected_config_directory
    assert context.config_files.config_properties_filenames is None
    assert context.config_files.config_log_filename is None
Esempio n. 22
0
def setup_driver(scenario):
    """Scenario initialization

    :param scenario: running scenario
    """
    if not hasattr(world, 'config_files'):
        world.config_files = ConfigFiles()

    # By default config directory is located in terrain path
    if not world.config_files.config_directory:
        world.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

    world.global_status = {'test_passed': True}
    bdd_common_before_scenario(world, scenario)
Esempio n. 23
0
 def setUp(self):
     # Configure properties
     config_files = ConfigFiles()
     root_path = os.path.dirname(os.path.dirname(
         os.path.realpath(__file__)))
     config_files.set_config_directory(os.path.join(root_path, 'conf'))
     config_files.set_config_properties_filenames('properties.cfg')
     self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
     self.driver_wrapper.configure(tc_config_files=config_files)
Esempio n. 24
0
def driver_wrapper():
    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    new_driver_wrapper = DriverWrappersPool.get_default_wrapper()

    # Configure wrapper
    config_files = ConfigFiles()
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    config_files.set_config_log_filename('logging.conf')
    new_driver_wrapper.configure(config_files)

    return new_driver_wrapper
Esempio n. 25
0
def test_before_all_config_environment(create_and_configure_wrapper, property_name):
    # Create context mock
    context = mock.MagicMock()
    context.config.userdata.get.side_effect = lambda x: 'os' if x == property_name else None
    context.config_files = ConfigFiles()

    before_all(context)

    # Check that configuration folder is the same as environment folder and property 'Config_environment' is configured
    expected_config_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'conf')
    assert context.config_files.config_directory == expected_config_directory
    assert context.config_files.config_properties_filenames == 'properties.cfg;os-properties.cfg;local-os-properties.cfg'
    assert context.config_files.config_log_filename is None
    assert os.environ['Config_environment'] == 'os'
    del os.environ["Config_environment"]
Esempio n. 26
0
def test_configure_change_configuration_file(driver_wrapper):
    # Check previous values
    assert driver_wrapper.config.get('Driver', 'type') == 'firefox'

    # Modify wrapper
    driver_wrapper.config.set('Driver', 'type', 'opera')

    # Change properties file and try to configure again
    root_path = os.path.dirname(os.path.realpath(__file__))
    environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')
    os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = os.path.join(
        root_path, 'conf', 'android-properties.cfg')
    driver_wrapper.configure(ConfigFiles())

    # Check that configuration has been initialized
    assert driver_wrapper.config.get('Driver', 'type') == 'android'
Esempio n. 27
0
def test_configure_change_configuration_file(driver_wrapper):
    # Check previous values
    assert driver_wrapper.config.get('Driver', 'type') == 'firefox'

    # Modify wrapper
    driver_wrapper.config.set('Driver', 'type', 'opera')

    # Change properties file and try to configure again
    root_path = os.path.dirname(os.path.realpath(__file__))
    os.environ["Config_prop_filenames"] = os.path.join(
        root_path, 'conf', 'android-properties.cfg')
    driver_wrapper.configure(ConfigFiles())
    del os.environ["Config_prop_filenames"]

    # Check that configuration has been initialized
    assert driver_wrapper.config.get('Driver', 'type') == 'android'
Esempio n. 28
0
def test_initialize_config_files_configured():
    config_files = ConfigFiles()
    config_files.set_config_properties_filenames('test.conf', 'local-test.conf')
    config_files.set_output_log_filename('test.log')

    # Initialize config files
    config_files = DriverWrappersPool.initialize_config_files(config_files)

    # Check expected config files
    assert config_files.config_properties_filenames == 'test.conf;local-test.conf'
    assert config_files.output_log_filename == 'test.log'
Esempio n. 29
0
    def test_before_all_env(self, create_and_configure_wrapper):
        # Create context mock
        context = mock.MagicMock()
        context.config.userdata.get.return_value = 'os'
        context.config_files = ConfigFiles()

        before_all(context)

        # Check that configuration folder is the same as environment folder and configuration files are 'os' files
        expected_config_directory = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), 'conf')
        expected_config_properties_filenames = 'properties.cfg;os-properties.cfg;local-os-properties.cfg'
        assert_equal(context.config_files.config_directory,
                     expected_config_directory)
        assert_equal(context.config_files.config_properties_filenames,
                     expected_config_properties_filenames)
        assert_is_none(context.config_files.config_log_filename)
Esempio n. 30
0
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
        self.driver_wrapper.driver = mock.MagicMock()

        # Configure properties
        self.root_path = os.path.dirname(os.path.realpath(__file__))
        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_config_properties_filenames('properties.cfg')
        config_files.set_output_directory(os.path.join(self.root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)

        # Create a new Utils instance
        self.utils = Utils()
Esempio n. 31
0
def test_connect_api_from_file(driver_wrapper):
    # Mock data
    expected_driver = None

    # Change driver type to api and configure again
    root_path = os.path.dirname(os.path.realpath(__file__))
    environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')
    os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = os.path.join(
        root_path, 'conf', 'api-properties.cfg')
    driver_wrapper.configure(ConfigFiles())

    # Connect and check that the returned driver is None
    assert driver_wrapper.connect(
    ) == expected_driver  # Check that the wrapper has been configured
    assert driver_wrapper.config.get('Driver', 'type') == ''
    assert driver_wrapper.config.get('Jira', 'enabled') == 'false'
    logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
    assert logging.getLevelName(logger.level) == 'DEBUG'
Esempio n. 32
0
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()

        # Create default wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()

        # Configure properties
        config_files = ConfigFiles()
        root_path = os.path.dirname(os.path.realpath(__file__))
        config_files.set_config_directory(os.path.join(root_path, 'conf'))
        config_files.set_output_directory(os.path.join(root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)
Esempio n. 33
0
def driver_wrapper():
    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    new_driver_wrapper = DriverWrappersPool.get_default_wrapper()

    # Configure wrapper
    config_files = ConfigFiles()
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    config_files.set_config_log_filename('logging.conf')
    new_driver_wrapper.configure(config_files)

    return new_driver_wrapper
Esempio n. 34
0
def test_connect_api_from_file(driver_wrapper):
    # Mock data
    expected_driver = None

    # Change driver type to api and configure again
    root_path = os.path.dirname(os.path.realpath(__file__))
    os.environ["Config_prop_filenames"] = os.path.join(root_path, 'conf',
                                                       'api-properties.cfg')
    driver_wrapper.configure(ConfigFiles())
    del os.environ["Config_prop_filenames"]

    # Connect and check that the returned driver is None
    assert driver_wrapper.connect(
        maximize=False
    ) == expected_driver  # Check that the wrapper has been configured
    assert driver_wrapper.config.get('Driver', 'type') == ''
    assert driver_wrapper.config.get('Jira', 'enabled') == 'false'
    logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
    assert logging.getLevelName(logger.level) == 'DEBUG'
Esempio n. 35
0
def test_initialize_config_files_configured_environment():
    config_files = ConfigFiles()
    config_files.set_config_properties_filenames('test.conf',
                                                 'local-test.conf')
    config_files.set_output_log_filename('test.log')
    os.environ["Config_environment"] = 'android'

    # Initialize config files
    init_config_files = DriverWrapper._initialize_config_files(config_files)
    del os.environ["Config_environment"]

    # Check expected config files
    assert init_config_files.config_properties_filenames == 'test.conf;local-test.conf;android-test.conf;local-android-test.conf'
    assert init_config_files.output_log_filename == 'test_android.log'
Esempio n. 36
0
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()

        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_output_directory(
            os.path.join(self.root_path, 'output'))
        DriverWrappersPool.configure_common_directories(config_files)
        self.driver_wrapper.configure_properties()
Esempio n. 37
0
def test_initialize_config_files_configured_environment_with_points():
    config_files = ConfigFiles()
    config_files.set_config_properties_filenames('test.new.conf', 'local-test.new.conf')
    config_files.set_output_log_filename('test.new.log')
    os.environ['TOOLIUM_CONFIG_ENVIRONMENT'] = 'ios'

    # Initialize config files
    config_files = DriverWrappersPool.initialize_config_files(config_files)
    del os.environ['TOOLIUM_CONFIG_ENVIRONMENT']

    # Check expected config files
    expected_properties_filenames = 'test.new.conf;local-test.new.conf;ios-test.new.conf;local-ios-test.new.conf'
    assert config_files.config_properties_filenames == expected_properties_filenames
    assert config_files.output_log_filename == 'test.new_ios.log'
Esempio n. 38
0
    def setUp(self):
        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
        self.driver_wrapper.driver = mock.MagicMock()

        # Configure properties
        self.root_path = os.path.dirname(os.path.realpath(__file__))
        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_config_properties_filenames('properties.cfg')
        config_files.set_output_directory(os.path.join(self.root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)

        # Create a new Utils instance
        self.utils = Utils()
Esempio n. 39
0
def driver_wrapper():
    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None

    # Create a new wrapper
    driver_wrapper = DriverWrappersPool.get_default_wrapper()
    driver_wrapper.driver = mock.MagicMock()

    # Configure properties
    root_path = os.path.dirname(os.path.realpath(__file__))
    config_files = ConfigFiles()
    config_files.set_config_directory(os.path.join(root_path, 'conf'))
    config_files.set_config_properties_filenames('properties.cfg')
    config_files.set_output_directory(os.path.join(root_path, 'output'))
    driver_wrapper.configure(config_files)

    yield driver_wrapper

    # Reset wrappers pool values
    DriverWrappersPool._empty_pool()
    DriverWrapper.config_properties_filenames = None
Esempio n. 40
0
    def setUp(self):
        # Remove previous visual path
        visual_path = os.path.join(self.root_path, 'output', 'visualtests')
        if os.path.exists(visual_path):
            shutil.rmtree(visual_path)

        # Reset wrappers pool values
        DriverWrappersPool._empty_pool()
        DriverWrapper.config_properties_filenames = None

        # Create a new wrapper
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
        self.driver_wrapper.driver = mock.MagicMock()

        # Configure properties
        config_files = ConfigFiles()
        config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
        config_files.set_config_properties_filenames('properties.cfg')
        config_files.set_output_directory(os.path.join(self.root_path, 'output'))
        self.driver_wrapper.configure(tc_config_files=config_files)
        self.driver_wrapper.config.set('VisualTests', 'enabled', 'true')

        # Create a new VisualTest instance
        self.visual = VisualTest(self.driver_wrapper)
Esempio n. 41
0
 def test_set_output_directory(self):
     config_files = ConfigFiles()
     directory = '/tmp/fake'
     config_files.set_output_directory(directory)
     assert_equal(directory, config_files.output_directory)
Esempio n. 42
0
 def test_set_config_log_filename(self):
     config_files = ConfigFiles()
     filename = 'logging.conf'
     config_files.set_config_log_filename(filename)
     assert_equal(filename, config_files.config_log_filename)
Esempio n. 43
0
 def test_set_output_log_filename(self):
     config_files = ConfigFiles()
     filename = 'output.log'
     config_files.set_output_log_filename(filename)
     assert_equal(filename, config_files.output_log_filename)
Esempio n. 44
0
 def setUp(self):
     self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
     config_files = ConfigFiles()
     config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
     config_files.set_output_directory(os.path.join(self.root_path, 'output'))
     DriverWrappersPool.configure_common_directories(config_files)
Esempio n. 45
0
 def test_set_config_properties_filenames(self):
     config_files = ConfigFiles()
     config_files.set_config_properties_filenames('properties.cfg', 'local-properties.cfg')
     assert_equal('properties.cfg;local-properties.cfg', config_files.config_properties_filenames)