Skip to content

Commit

Permalink
Test fsspec register and class import (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua authored Oct 16, 2024
1 parent 6e6859f commit 897c922
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tosfs/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://",
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions tosfs/tests/test_fsspec_integration.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 897c922

Please sign in to comment.