示例#1
0
    def test_resolve_all_returns_all_paths_in_dirs_when_given_no_subpaths(
            self):
        empty_dir_1 = tempfile.mkdtemp()
        empty_dir_2 = tempfile.mkdtemp()

        dirs = [empty_dir_1, empty_dir_2]
        ret = multipath.resolve_all(dirs)

        self.assertEqual(ret, dirs)
示例#2
0
文件: path.py 项目: adamkewley/lor
def resolve_all(*paths):
    """
    Returns a list of paths created by joining paths onto each dir in overlay_dirs + the workspace using os.path.join
    and discarding all join results that do not exist.

    :param paths: Path components to join
    :return: A list of paths created by joining paths onto each dir in overlay_dirs + the workspace using os.path.join
    """
    return multipath.resolve_all(__get_dirs(), *paths)
示例#3
0
    def test_resolve_all_returns_expected_result_for_nominal_case(self):
        empty_dir = tempfile.mkdtemp()
        dir_containing_file = tempfile.mkdtemp()

        frag1 = "somefile"

        self.__create_empty_file(os.path.join(dir_containing_file, frag1))

        ret = multipath.resolve_all([empty_dir, dir_containing_file], frag1)

        self.assertEqual(ret, [os.path.join(dir_containing_file, frag1)])
示例#4
0
    def test_resolve_all_returns_empty_list_if_subpath_doesnt_exist_in_any_dir(
            self):
        empty_dir_1 = tempfile.mkdtemp()
        empty_dir_2 = tempfile.mkdtemp()
        empty_dir_3 = tempfile.mkdtemp()

        path = "some/path"

        ret = multipath.resolve_all([empty_dir_1, empty_dir_2, empty_dir_3],
                                    path)

        self.assertEqual([], ret)
示例#5
0
    def test_resolve_all_returns_all_existient_paths(self):
        empty_dir = tempfile.mkdtemp()
        first_dir_with_file = tempfile.mkdtemp()
        second_dir_with_file = tempfile.mkdtemp()

        path = "somefile"

        self.__create_empty_file(os.path.join(first_dir_with_file, path))
        self.__create_empty_file(os.path.join(second_dir_with_file, path))

        ret = multipath.resolve_all(
            [empty_dir, first_dir_with_file, second_dir_with_file], path)

        expected_ret = [
            os.path.join(first_dir_with_file, path),
            os.path.join(second_dir_with_file, path),
        ]

        self.assertEqual(ret, expected_ret)