def test_catalog_release(self, mocker):
     fs_mock = mocker.patch("fsspec.filesystem").return_value
     filepath = "test.png"
     data_set = HoloviewsWriter(filepath=filepath)
     assert data_set._version_cache.currsize == 0  # no cache if unversioned
     data_set.release()
     fs_mock.invalidate_cache.assert_called_once_with(filepath)
     assert data_set._version_cache.currsize == 0
    def test_open_extra_args(self, tmp_path, fs_args, mocker):
        fs_mock = mocker.patch("fsspec.filesystem")
        writer = HoloviewsWriter(str(tmp_path), fs_args)

        fs_mock.assert_called_once_with("file",
                                        auto_mkdir=True,
                                        storage_option="value")
        assert writer._fs_open_args_save == fs_args["open_args_save"]
    def test_protocol_usage(self, filepath, instance_type, credentials):
        data_set = HoloviewsWriter(filepath=filepath, credentials=credentials)
        assert isinstance(data_set._fs, instance_type)

        path = filepath.split(PROTOCOL_DELIMITER, 1)[-1]

        assert str(data_set._filepath) == path
        assert isinstance(data_set._filepath, PurePosixPath)
Example #4
0
    def test_protocol_usage(self, filepath, instance_type, credentials):
        data_set = HoloviewsWriter(filepath=filepath, credentials=credentials)
        assert isinstance(data_set._fs, instance_type)

        # _strip_protocol() doesn't strip http(s) protocol
        if data_set._protocol == "https":
            path = filepath.split("://")[-1]
        else:
            path = data_set._fs._strip_protocol(filepath)

        assert str(data_set._filepath) == path
        assert isinstance(data_set._filepath, PurePosixPath)
def versioned_hv_writer(filepath_png, load_version, save_version):
    return HoloviewsWriter(filepath_png,
                           version=Version(load_version, save_version))
def hv_writer(filepath_png, save_args, fs_args):
    return HoloviewsWriter(filepath_png, save_args=save_args, fs_args=fs_args)
    def test_http_filesystem_no_versioning(self):
        pattern = r"HTTP\(s\) DataSet doesn't support versioning\."

        with pytest.raises(DataSetError, match=pattern):
            HoloviewsWriter(filepath="https://example.com/file.png",
                            version=Version(None, None))