diff --git a/tosfs/tests/conftest.py b/tosfs/tests/conftest.py index 16ab5b6..be549a4 100644 --- a/tosfs/tests/conftest.py +++ b/tosfs/tests/conftest.py @@ -49,7 +49,7 @@ def tosfs(_tosfs_env_prepare: None) -> TosFileSystem: @pytest.fixture(scope="module") def fsspecfs(_tosfs_env_prepare: None) -> Any: - known_implementations["tos"] = {"class": "tosfs.core.TosFileSystem"} + known_implementations["tos"] = {"class": "tosfs.TosFileSystem"} fsspecfs, _ = fsspec.core.url_to_fs( "tos://", diff --git a/tosfs/tests/test_fsspec_integration.py b/tosfs/tests/test_fsspec_integration.py new file mode 100644 index 0000000..d9facd5 --- /dev/null +++ b/tosfs/tests/test_fsspec_integration.py @@ -0,0 +1,43 @@ +# ByteDance Volcengine EMR, Copyright 2024. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import fsspec +from fsspec.registry import known_implementations +from tos import EnvCredentialsProvider + + +def test_fssepc_register(): + fsspec.register_implementation("tos", "tosfs.TosFileSystem") + + tosfs, _ = fsspec.core.url_to_fs( + "tos://", + endpoint_url=os.environ.get("TOS_ENDPOINT"), + region=os.environ.get("TOS_REGION"), + credentials_provider=EnvCredentialsProvider(), + ) + assert len(tosfs.ls("")) > 0 + + +def test_set_known_implementations(): + known_implementations["tos"] = {"class": "tosfs.core.TosFileSystem"} + + tosfs, _ = fsspec.core.url_to_fs( + "tos://", + endpoint_url=os.environ.get("TOS_ENDPOINT"), + region=os.environ.get("TOS_REGION"), + credentials_provider=EnvCredentialsProvider(), + ) + assert len(tosfs.ls("")) > 0 diff --git a/tosfs/tests/test_tosfs.py b/tosfs/tests/test_tosfs.py index 8a06fe0..8b72379 100644 --- a/tosfs/tests/test_tosfs.py +++ b/tosfs/tests/test_tosfs.py @@ -17,7 +17,7 @@ import pytest from tos.exceptions import TosServerError -from tosfs.core import TosFileSystem +from tosfs import TosFileSystem from tosfs.exceptions import TosfsError from tosfs.utils import create_temp_dir, random_str