示例#1
0
    def test_simple_LinkPathAction_softlink(self):
        if not softlink_supported(__file__, self.prefix) and on_win:
            pytest.skip("softlink not supported")

        source_full_path = make_test_file(self.pkgs_dir)
        target_short_path = source_short_path = basename(source_full_path)

        correct_sha256 = compute_sha256sum(source_full_path)
        correct_size_in_bytes = getsize(source_full_path)
        path_type = PathType.hardlink

        source_path_data = PathDataV1(
            _path = source_short_path,
            path_type=path_type,
            sha256=correct_sha256,
            size_in_bytes=correct_size_in_bytes,
        )

        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path, self.prefix,
                             target_short_path, LinkType.softlink, source_path_data)

        assert axn.target_full_path == join(self.prefix, target_short_path)
        axn.verify()
        axn.execute()
        assert isfile(axn.target_full_path)
        assert islink(axn.target_full_path)
        assert stat_nlink(axn.target_full_path) == 1

        axn.reverse()
        assert not lexists(axn.target_full_path)
        assert lexists(source_full_path)
示例#2
0
    def test_simple_LinkPathAction_copy(self):
        source_full_path = make_test_file(self.pkgs_dir)
        target_short_path = source_short_path = basename(source_full_path)

        correct_sha256 = compute_sha256sum(source_full_path)
        correct_size_in_bytes = getsize(source_full_path)
        path_type = PathType.hardlink

        source_path_data = PathDataV1(
            _path = source_short_path,
            path_type=path_type,
            sha256=correct_sha256,
            size_in_bytes=correct_size_in_bytes,
        )

        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path, self.prefix,
                             target_short_path, LinkType.copy, source_path_data)

        assert axn.target_full_path == join(self.prefix, target_short_path)
        axn.verify()
        axn.execute()
        assert isfile(axn.target_full_path)
        assert not islink(axn.target_full_path)
        assert stat_nlink(axn.target_full_path) == 1

        axn.reverse()
        assert not lexists(axn.target_full_path)
示例#3
0
    def test_simple_LinkPathAction_directory(self):
        target_short_path = join('a', 'nested', 'directory')
        axn = LinkPathAction({}, None, None, None, self.prefix,
                             target_short_path, LinkType.directory)
        axn.verify()
        axn.execute()

        assert isdir(join(self.prefix, target_short_path))

        axn.reverse()
        assert not lexists(axn.target_full_path)
        assert not lexists(dirname(axn.target_full_path))
        assert not lexists(dirname(dirname(axn.target_full_path)))
示例#4
0
    def test_simple_LinkPathAction_copy(self):
        source_full_path = make_test_file(self.pkgs_dir)
        target_short_path = source_short_path = basename(source_full_path)
        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path,
                             self.prefix, target_short_path, LinkType.copy)

        assert axn.target_full_path == join(self.prefix, target_short_path)
        axn.verify()
        axn.execute()
        assert isfile(axn.target_full_path)
        assert not islink(axn.target_full_path)
        assert stat_nlink(axn.target_full_path) == 1

        axn.reverse()
        assert not lexists(axn.target_full_path)
示例#5
0
    def test_simple_LinkPathAction_directory(self):
        target_short_path = join('a', 'nested', 'directory')
        axn = LinkPathAction({}, None, None, None, self.prefix,
                             target_short_path, LinkType.directory, None)
        axn.verify()
        axn.execute()

        assert isdir(join(self.prefix, target_short_path))

        axn.reverse()
        # this is counter-intuitive, but it's faster to tell conda to ignore folders for removal in transactions
        #    than it is to try to have it scan to see if anything else has populated that folder.
        assert lexists(axn.target_full_path)
        assert lexists(dirname(axn.target_full_path))
        assert lexists(dirname(dirname(axn.target_full_path)))