Skip to content

Commit

Permalink
add sftp registration (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
uunal authored Sep 5, 2023
1 parent dca7d9b commit 67b9f38
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ pywin32 = asyncssh[pywin32]
[options.entry_points]
fsspec.specs =
ssh = sshfs.spec:SSHFileSystem
sftp = sshfs.spec:SSHFileSystem
42 changes: 22 additions & 20 deletions tests/test_sshfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import tempfile
import warnings
from concurrent import futures
from datetime import datetime, timedelta
from pathlib import Path

import fsspec
import pkg_resources
import pytest
from asyncssh.sftp import SFTPFailure

Expand Down Expand Up @@ -73,28 +73,30 @@ def strip_keys(info):


def test_fsspec_registration(ssh_server):
fs = fsspec.filesystem(
"ssh",
host=ssh_server.host,
port=ssh_server.port,
username="user",
client_keys=[USERS["user"]],
)
assert isinstance(fs, SSHFileSystem)
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
fs = fsspec.filesystem(
ep.name,
host=ssh_server.host,
port=ssh_server.port,
username="user",
client_keys=[USERS["user"]],
)
assert isinstance(fs, SSHFileSystem)


def test_fsspec_url_parsing(ssh_server, remote_dir, user="user"):
url = f"ssh://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
# Check the underlying file system.
file_fs = file.buffer.fs
assert isinstance(file_fs, SSHFileSystem)
assert file_fs.storage_options == {
"host": ssh_server.host,
"port": ssh_server.port,
"username": user,
"client_keys": [USERS[user]],
}
for ep in pkg_resources.iter_entry_points(group="fsspec.specs"):
url = f"{ep.name}://{user}@{ssh_server.host}:{ssh_server.port}/{remote_dir}/file"
with fsspec.open(url, "w", client_keys=[USERS[user]]) as file:
# Check the underlying file system.
file_fs = file.buffer.fs
assert isinstance(file_fs, SSHFileSystem)
assert file_fs.storage_options == {
"host": ssh_server.host,
"port": ssh_server.port,
"username": user,
"client_keys": [USERS[user]],
}


def test_info(fs, remote_dir):
Expand Down

0 comments on commit 67b9f38

Please sign in to comment.