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

        with pytest.raises(DataSetError, match=pattern):
            YAMLDataSet(
                filepath="https://example.com/file.yaml", version=Version(None, None)
            )
예제 #2
0
    def test_protocol_usage(self, filepath, instance_type):
        data_set = YAMLDataSet(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)
예제 #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.yaml"
        ds = YAMLDataSet(filepath=filepath)
        ds_versioned = YAMLDataSet(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 "YAMLDataSet" in str(ds_versioned)
        assert "YAMLDataSet" in str(ds)
        assert "protocol" in str(ds_versioned)
        assert "protocol" in str(ds)
        # Default save_args
        assert "save_args={'default_flow_style': False}" in str(ds)
        assert "save_args={'default_flow_style': False}" in str(ds_versioned)
예제 #4
0
    def test_protocol_usage(self, filepath, instance_type):
        data_set = YAMLDataSet(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)
예제 #5
0
def versioned_yaml_data_set(filepath_yaml, load_version, save_version):
    return YAMLDataSet(filepath=filepath_yaml,
                       version=Version(load_version, save_version))
예제 #6
0
def yaml_data_set(filepath_yaml, save_args, fs_args):
    return YAMLDataSet(filepath=filepath_yaml,
                       save_args=save_args,
                       fs_args=fs_args)
예제 #7
0
 def test_catalog_release(self, mocker):
     fs_mock = mocker.patch("fsspec.filesystem").return_value
     filepath = "test.yaml"
     data_set = YAMLDataSet(filepath=filepath)
     data_set.release()
     fs_mock.invalidate_cache.assert_called_once_with(filepath)