コード例 #1
0
    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'])
コード例 #2
0
    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'])
コード例 #3
0
ファイル: test_content_utils.py プロジェクト: rlugojr/st2
    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"])
コード例 #4
0
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
コード例 #5
0
ファイル: aliasesregistrar.py プロジェクト: ravidsinghbiz/st2
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