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

        with pytest.raises(DataSetError, match=pattern):
            GeoJSONDataSet(
                filepath="https://example/file.geojson", version=Version(None, None)
            )
Esempio n. 2
0
    def test_protocol_usage(self, filepath, instance_type):
        geojson_data_set = GeoJSONDataSet(filepath=filepath)
        assert isinstance(geojson_data_set._fs, instance_type)

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

        assert str(geojson_data_set._filepath) == path
        assert isinstance(geojson_data_set._filepath, PurePosixPath)
    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.geojson"
        ds = GeoJSONDataSet(filepath=filepath)
        ds_versioned = GeoJSONDataSet(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 "GeoJSONDataSet" in str(ds_versioned)
        assert "GeoJSONDataSet" in str(ds)
        assert "protocol" in str(ds_versioned)
        assert "protocol" in str(ds)
    def test_protocol_usage(self, filepath, instance_type):
        geojson_data_set = GeoJSONDataSet(filepath=filepath)
        assert isinstance(geojson_data_set._fs, instance_type)

        if geojson_data_set._protocol == "https":
            path = filepath.split("://")[-1]
        else:
            path = geojson_data_set._fs._strip_protocol(filepath)

        assert str(geojson_data_set._filepath) == path
        assert isinstance(geojson_data_set._filepath, PurePosixPath)
Esempio n. 5
0
def versioned_geojson_data_set(filepath, load_version, save_version):
    return GeoJSONDataSet(filepath=filepath,
                          version=Version(load_version, save_version))
Esempio n. 6
0
def geojson_data_set(filepath, load_args, save_args, fs_args):
    return GeoJSONDataSet(filepath=filepath,
                          load_args=load_args,
                          save_args=save_args,
                          fs_args=fs_args)
Esempio n. 7
0
 def test_catalog_release(self, mocker):
     fs_mock = mocker.patch("fsspec.filesystem").return_value
     filepath = "test.geojson"
     geojson_data_set = GeoJSONDataSet(filepath=filepath)
     geojson_data_set.release()
     fs_mock.invalidate_cache.assert_called_once_with(filepath)