Example #1
0
    def test_http_filesystem_no_versioning(self):
        pattern = r"HTTP\(s\) DataSet doesn't support versioning\."

        with pytest.raises(DataSetError, match=pattern):
            FeatherDataSet(
                filepath="https://example.com/file.feather", version=Version(None, None)
            )
Example #2
0
    def test_protocol_usage(self, filepath, instance_type):
        data_set = FeatherDataSet(filepath=filepath)
        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 #3
0
    def test_version_str_repr(self, load_version, save_version):
        """Test that version is in string representation of the class instance
        when applicable."""
        filepath = "test.feather"
        ds = FeatherDataSet(filepath=filepath)
        ds_versioned = FeatherDataSet(
            filepath=filepath, version=Version(load_version, save_version)
        )
        assert filepath in str(ds)
        assert "version" not in str(ds)

        assert filepath in str(ds_versioned)
        ver_str = f"version=Version(load={load_version}, save='{save_version}')"
        assert ver_str in str(ds_versioned)
        assert "FeatherDataSet" in str(ds_versioned)
        assert "FeatherDataSet" in str(ds)
        assert "protocol" in str(ds_versioned)
        assert "protocol" in str(ds)
    def test_protocol_usage(self, filepath, instance_type):
        data_set = FeatherDataSet(filepath=filepath)
        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)
Example #5
0
def versioned_feather_data_set(filepath_feather, load_version, save_version):
    return FeatherDataSet(
        filepath=filepath_feather, version=Version(load_version, save_version)
    )
Example #6
0
def feather_data_set(filepath_feather, load_args, fs_args):
    return FeatherDataSet(
        filepath=filepath_feather, load_args=load_args, fs_args=fs_args
    )
Example #7
0
 def test_catalog_release(self, mocker):
     fs_mock = mocker.patch("fsspec.filesystem").return_value
     filepath = "test.feather"
     data_set = FeatherDataSet(filepath=filepath)
     data_set.release()
     fs_mock.invalidate_cache.assert_called_once_with(filepath)