Exemple #1
0
 def test_path_object_and_str_are_valid_arg_types(self):
     base_path = "foo"
     target_path = os.path.join(base_path, "bar")
     self.assertFalse(contains_symlink_up_to(target_path, base_path))
     self.assertFalse(
         contains_symlink_up_to(PathInfo(target_path), PathInfo(base_path))
     )
Exemple #2
0
def test_should_return_false_on_no_more_dirs_below_path(mocker):
    mocker.patch.object(system, "is_symlink", return_value=False)
    dirname_patch = mocker.patch.object(os.path,
                                        "dirname",
                                        side_effect=lambda arg: arg)
    assert not contains_symlink_up_to(os.path.join("foo", "path"), "foo")
    dirname_patch.assert_called_once()
Exemple #3
0
 def test_should_return_false_on_no_more_dirs_below_path(
     self, dirname_patch, _
 ):
     self.assertFalse(
         contains_symlink_up_to(os.path.join("foo", "path"), "foo")
     )
     dirname_patch.assert_called_once()
Exemple #4
0
 def _expand_to_path_on_add_local(add, fname, out, path_handler):
     if (
         add
         and out.is_local
         and not contains_symlink_up_to(out.path, out.repo.root_dir)
     ):
         fname = path_handler.join(path_handler.dirname(out.path), fname)
     return fname
Exemple #5
0
    def _stage_fname(cls, outs, add):
        if not outs:
            return cls.STAGE_FILE

        out = outs[0]
        fname = out.path_info.name + cls.STAGE_FILE_SUFFIX

        if (add and out.is_in_repo
                and not contains_symlink_up_to(out.fspath, out.repo.root_dir)):
            fname = out.path_info.with_name(fname).fspath

        return fname
Exemple #6
0
    def test_should_return_false_when_base_path_is_symlink(self, _):
        base_path = "foo"
        target_path = os.path.join(base_path, "bar")

        def base_path_is_symlink(path):
            if path == base_path:
                return True
            return False

        with patch.object(
            System, "is_symlink", side_effect=base_path_is_symlink
        ):
            self.assertFalse(contains_symlink_up_to(target_path, base_path))
Exemple #7
0
def test_should_return_false_when_base_path_is_symlink(mocker):
    base_path = "foo"
    target_path = os.path.join(base_path, "bar")

    def base_path_is_symlink(path):
        if path == base_path:
            return True
        return False

    mocker.patch.object(
        system,
        "is_symlink",
        return_value=True,
        side_effect=base_path_is_symlink,
    )
    assert not contains_symlink_up_to(target_path, base_path)
Exemple #8
0
 def test_should_return_false_on_path_eq_to_base_path(self, _):
     path = "path"
     self.assertFalse(contains_symlink_up_to(path, path))
Exemple #9
0
 def test_should_return_true_on_symlink_in_path(self, _):
     base_path = "foo"
     path = os.path.join(base_path, "bar")
     self.assertTrue(contains_symlink_up_to(path, base_path))
Exemple #10
0
 def test_should_raise_exception_on_base_path_not_in_path(self):
     with self.assertRaises(BasePathNotInCheckedPathException):
         contains_symlink_up_to(os.path.join("foo", "path"), "bar")
Exemple #11
0
def test_path_object_and_str_are_valid_arg_types():
    base_path = "foo"
    target_path = os.path.join(base_path, "bar")
    assert not contains_symlink_up_to(target_path, base_path)
    assert not contains_symlink_up_to(target_path, base_path)
Exemple #12
0
def test_should_return_false_on_path_eq_to_base_path(mocker):
    mocker.patch.object(system, "is_symlink", return_value=False)
    path = "path"
    assert not contains_symlink_up_to(path, path)
Exemple #13
0
def test_should_return_true_on_symlink_in_path(mocker):
    mocker.patch.object(system, "is_symlink", return_value=True)
    base_path = "foo"
    path = os.path.join(base_path, "bar")
    assert contains_symlink_up_to(path, base_path)
Exemple #14
0
def test_contains_symlink_case_sensitive_posix():
    child = os.path.join("path", "to", "folder")
    parent = os.path.join("PATH", "TO")
    with pytest.raises(BasePathNotInCheckedPathException):
        contains_symlink_up_to(child, parent)
Exemple #15
0
def test_contains_symlink_case_sensitive_win():
    child = os.path.join("path", "to", "folder")
    parent = os.path.join("PATH", "TO")
    assert contains_symlink_up_to(child, parent) is False