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
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
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)
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
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)
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 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)
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'
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'
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'
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()
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
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)
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)