def test_http_filesystem_no_versioning(self): pattern = r"HTTP\(s\) DataSet doesn't support versioning\." with pytest.raises(DataSetError, match=pattern): JSONDataSet( filepath="https://example.com/file.json", version=Version(None, None) )
def test_protocol_usage(self, filepath, instance_type): data_set = JSONDataSet(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)
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.json" ds = JSONDataSet(filepath=filepath) ds_versioned = JSONDataSet(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 "JSONDataSet" in str(ds_versioned) assert "JSONDataSet" in str(ds) assert "protocol" in str(ds_versioned) assert "protocol" in str(ds) # Default save_args assert "save_args={'indent': 2}" in str(ds) assert "save_args={'indent': 2}" in str(ds_versioned)
def versioned_json_data_set(filepath_json, load_version, save_version): return JSONDataSet(filepath=filepath_json, version=Version(load_version, save_version))
def json_data_set(filepath_json, save_args, fs_args): return JSONDataSet(filepath=filepath_json, save_args=save_args, fs_args=fs_args)
def test_catalog_release(self, mocker): fs_mock = mocker.patch("fsspec.filesystem").return_value filepath = "test.json" data_set = JSONDataSet(filepath=filepath) data_set.release() fs_mock.invalidate_cache.assert_called_once_with(filepath)