def test_get_aliases_base_paths(self): cfg.CONF.content.aliases_base_paths = '/opt/path1' result = get_aliases_base_paths() self.assertEqual(result, ['/opt/path1']) # Multiple paths, no trailing colon cfg.CONF.content.aliases_base_paths = '/opt/path1:/opt/path2' result = get_aliases_base_paths() self.assertEqual(result, ['/opt/path1', '/opt/path2']) # Multiple paths, trailing colon cfg.CONF.content.aliases_base_paths = '/opt/path1:/opt/path2:' result = get_aliases_base_paths() self.assertEqual(result, ['/opt/path1', '/opt/path2']) # Multiple same paths cfg.CONF.content.aliases_base_paths = '/opt/path1:/opt/path2:/opt/path1:/opt/path2' result = get_aliases_base_paths() self.assertEqual(result, ['/opt/path1', '/opt/path2'])
def test_get_aliases_base_paths(self): cfg.CONF.content.aliases_base_paths = "/opt/path1" result = get_aliases_base_paths() self.assertEqual(result, ["/opt/path1"]) # Multiple paths, no trailing colon cfg.CONF.content.aliases_base_paths = "/opt/path1:/opt/path2" result = get_aliases_base_paths() self.assertEqual(result, ["/opt/path1", "/opt/path2"]) # Multiple paths, trailing colon cfg.CONF.content.aliases_base_paths = "/opt/path1:/opt/path2:" result = get_aliases_base_paths() self.assertEqual(result, ["/opt/path1", "/opt/path2"]) # Multiple same paths cfg.CONF.content.aliases_base_paths = "/opt/path1:/opt/path2:/opt/path1:/opt/path2" result = get_aliases_base_paths() self.assertEqual(result, ["/opt/path1", "/opt/path2"])
def register_aliases(aliases_base_paths=None, aliases_dir=None): if aliases_base_paths: assert(isinstance(aliases_base_paths, list)) registrar = AliasesRegistrar() if aliases_dir: result = registrar.register_aliases_from_dir(aliases_dir=aliases_dir) else: if not aliases_base_paths: aliases_base_paths = content_utils.get_aliases_base_paths() result = registrar.register_aliases_from_dirs(aliases_dirs=aliases_base_paths) return result
def register_aliases(aliases_base_paths=None, aliases_dir=None): if aliases_base_paths: assert (isinstance(aliases_base_paths, list)) registrar = AliasesRegistrar() if aliases_dir: result = registrar.register_aliases_from_dir(aliases_dir=aliases_dir) else: if not aliases_base_paths: aliases_base_paths = content_utils.get_aliases_base_paths() result = registrar.register_aliases_from_dirs( aliases_dirs=aliases_base_paths) return result