Beispiel #1
0
def test_readlink_with_broken_relative_target(dest):
    target = os.path.join('..', 'source_only_files', 'bbb')
    dest_path = os.path.join(dest, 'bbb')
    os.symlink(target, dest_path)
    assert utils.readlink(dest_path) == pathlib.Path(target)
    assert (utils.readlink(dest_path, absolute_target=True)
            == pathlib.Path(dest) / pathlib.Path(target))
Beispiel #2
0
def test_readlink_with_absolute_target(dest, source_a):
    target = os.path.join(source_a, 'aaa')
    dest_path = os.path.join(dest, 'bbb')
    os.symlink(target, dest_path)
    assert utils.readlink(dest_path) == pathlib.Path(target)
    assert utils.readlink(dest_path, absolute_target=True) == pathlib.Path(target)
    assert utils.readlink(dest_path, absolute_target=True).exists()
    assert utils.readlink(dest_path).exists()
Beispiel #3
0
def test_readlink_with_relative_target(dest, source_a):
    # pylint: disable=unused-argument
    # disable lint errors for source_a since we don't use the variable but use
    # the fixture
    target = os.path.join('..', 'source_a', 'aaa')
    dest_path = os.path.join(dest, 'bbb')
    os.symlink(target, dest_path)
    assert utils.readlink(dest_path) == pathlib.Path(target)
    assert (utils.readlink(dest_path, absolute_target=True) ==
            pathlib.Path(dest) / pathlib.Path(target))
    assert utils.readlink(dest_path, absolute_target=True).exists()
Beispiel #4
0
 def _collect_clean_actions(self, source, source_names, dest):
     subdests = utils.get_directory_contents(dest)
     for subdest in subdests:
         if subdest.is_symlink():
             link_target = utils.readlink(subdest, absolute_target=True)
             if (not link_target.exists() and not
                     source_names.isdisjoint(set(link_target.parents))):
                 self.actions.add(actions.UnLink(self.subcmd, subdest))
         elif subdest.is_dir():
             self._collect_clean_actions(source, source_names, subdest)
Beispiel #5
0
 def __repr__(self):
     return "dploy {subcmd}: unlink {target} => {source}".format(
         subcmd=self.subcmd, target=self.target, source=utils.readlink(self.target))