Files
dvc/tests/unit/fs/test_fs.py
T

38 lines
1.2 KiB
Python

import pytest
from dvc.config import RemoteNotFoundError
from dvc.fs import get_fs_cls, get_fs_config
from dvc.fs.hdfs import HDFSFileSystem
from dvc.fs.http import HTTPFileSystem
from dvc.fs.https import HTTPSFileSystem
from dvc.fs.local import LocalFileSystem
from dvc.fs.s3 import S3FileSystem
from dvc.fs.ssh import SSHFileSystem
@pytest.mark.parametrize(
"url, cls",
[
("s3://bucket/path", S3FileSystem),
("ssh://example.com:/dir/path", SSHFileSystem),
("hdfs://example.com/dir/path", HDFSFileSystem),
("http://example.com/path/to/file", HTTPFileSystem),
("https://example.com/path/to/file", HTTPSFileSystem),
("path/to/file", LocalFileSystem),
("path\\to\\file", LocalFileSystem),
("file", LocalFileSystem),
("./file", LocalFileSystem),
(".\\file", LocalFileSystem),
("../file", LocalFileSystem),
("..\\file", LocalFileSystem),
("unknown://path", LocalFileSystem),
],
)
def test_get_fs_cls(url, cls):
assert get_fs_cls({"url": url}) == cls
def test_get_fs_config():
with pytest.raises(RemoteNotFoundError):
get_fs_config({"remote": {}}, name="myremote")