def _assert_read_link(self, target):
        """Assert if the target path of the link is correct."""
        destination = os.path.join(self.basedir, target)
        make_link(self.testfile, destination)

        target = read_link(destination)
        self.assertEqual(self.testfile, target)
    def test_make_link(self):
        """The link is properly made."""
        destination = os.path.join(self.basedir, 'destination')
        make_link(self.testfile, destination)

        self.assertTrue(is_link(destination))
        self.assertEqual(os.path.normcase(self.testfile),
                         os.path.normcase(read_link(destination)))
Example #3
0
def create_shares_link(source, dest):
    """Create the shares symlink."""
    result = False
    if not path_exists(dest):
        # remove the symlink if it's broken
        if is_link(dest) and read_link(dest) != source:
            remove_link(dest)

        if not is_link(dest):
            # only create the link if it does not exist
            make_link(source, dest)
            result = True
    return result