def test_config_default_override(self): """LFN2PFN: Test override of default LFN2PFN algorithm via config (Success)""" if not config.config_has_section('policy'): config.config_add_section('policy') try: orig_value = config.config_get('policy', 'lfn2pfn_algorithm_default') except (NoOptionError, NoSectionError): orig_value = None def static_test(scope, name, rse, rse_attrs, proto_attrs): """Static test function for config override.""" del scope del name del rse del rse_attrs del proto_attrs return "static_test_value" RSEDeterministicTranslation.register(static_test) try: config.config_set('policy', 'lfn2pfn_algorithm_default', 'static_test') RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access assert_equal(self.translator.path("foo", "bar"), "static_test_value") finally: if orig_value is None: config.config_remove_option('policy', 'lfn2pfn_algorithm_default') else: config.config_set('policy', 'lfn2pfn_algorithm_default', orig_value) RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access
def test_module_load(self): """LFN2PFN: Test ability to provide LFN2PFN functions via module (Success)""" if not config.config_has_section('policy'): config.config_add_section('policy') config.config_set('policy', 'lfn2pfn_module', 'rucio.tests.lfn2pfn_module_test') RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access self.rse_attributes['lfn2pfn_algorithm'] = 'lfn2pfn_module_algorithm' self.create_translator() assert self.translator.path("foo", "bar") == "lfn2pfn_module_algorithm_value"