Skip to content

Commit

Permalink
updated fixture function and tests using get_filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
RRosio committed Feb 14, 2025
1 parent 1d0ad1c commit 76d8a78
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
7 changes: 4 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def setup_config_file_fs(tmp_path: Path, setup_tmp_local):
@pytest.fixture(scope="function")
def fs_manager_instance(setup_config_file_fs, s3_client):
fs_manager = setup_config_file_fs
fs_info = fs_manager.get_filesystem_by_protocol("memory")
mem_fs = fs_info["info"]["instance"]
mem_root_path = fs_info["info"]["path"]
fs_info = fs_manager.get_filesystem("TestMem Source")
print(f"fs_info: {fs_info}")
mem_fs = fs_info["instance"]
mem_root_path = fs_info["path"]

if mem_fs:
if mem_fs.exists(f"{mem_root_path}/test_dir"):
Expand Down
48 changes: 24 additions & 24 deletions jupyter_fsspec/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ async def test_get_config(jp_fetch):

async def test_get_files_memory(fs_manager_instance, jp_fetch):
fs_manager = fs_manager_instance
mem_fs_info = fs_manager.get_filesystem("TestMem Source")
mem_key = mem_fs_info["key"]
mem_fs = mem_fs_info["info"]["instance"]
mem_item_path = mem_fs_info["info"]["path"]
mem_key = "TestMem Source"
mem_fs_info = fs_manager.get_filesystem(mem_key)
mem_fs = mem_fs_info["instance"]
mem_item_path = mem_fs_info["path"]
assert mem_fs is not None

# Read directory
Expand Down Expand Up @@ -73,9 +73,9 @@ async def test_get_files_memory(fs_manager_instance, jp_fetch):

async def test_post_files(fs_manager_instance, jp_fetch):
fs_manager = fs_manager_instance
mem_fs_info = fs_manager.get_filesystem("TestMem Source")
mem_key = mem_fs_info["key"]
mem_fs = mem_fs_info["info"]["instance"]
mem_key = "TestMem Source"
mem_fs_info = fs_manager.get_filesystem(mem_key)
mem_fs = mem_fs_info["instance"]
assert mem_fs is not None

# Post new file with content
Expand Down Expand Up @@ -124,9 +124,9 @@ async def test_post_files(fs_manager_instance, jp_fetch):

async def test_delete_files(fs_manager_instance, jp_fetch):
fs_manager = fs_manager_instance
mem_fs_info = fs_manager.get_filesystem("TestMem Source")
mem_key = mem_fs_info["key"]
mem_fs = mem_fs_info["info"]["instance"]
mem_key = "TestMem Source"
mem_fs_info = fs_manager.get_filesystem(mem_key)
mem_fs = mem_fs_info["instance"]
assert mem_fs is not None

# Delete file
Expand Down Expand Up @@ -175,9 +175,9 @@ async def test_delete_files(fs_manager_instance, jp_fetch):
async def test_put_files(fs_manager_instance, jp_fetch):
# PUT replace entire resource
fs_manager = fs_manager_instance
mem_fs_info = fs_manager.get_filesystem("TestMem Source")
mem_key = mem_fs_info["key"]
mem_fs = mem_fs_info["info"]["instance"]
mem_key = "TestMem Source"
mem_fs_info = fs_manager.get_filesystem(mem_key)
mem_fs = mem_fs_info["instance"]
assert mem_fs is not None

# replace entire file content
Expand Down Expand Up @@ -217,9 +217,9 @@ async def test_put_files(fs_manager_instance, jp_fetch):

async def test_rename_files(fs_manager_instance, jp_fetch):
fs_manager = fs_manager_instance
mem_fs_info = fs_manager.get_filesystem("TestMem Source")
mem_key = mem_fs_info["key"]
mem_fs = mem_fs_info["info"]["instance"]
mem_key = "TestMem Source"
mem_fs_info = fs_manager.get_filesystem(mem_key)
mem_fs = mem_fs_info["instance"]
assert mem_fs is not None

# rename file
Expand Down Expand Up @@ -409,16 +409,16 @@ async def xtest_action_same_fs_files(fs_manager_instance, jp_fetch):

async def test_upload_download(fs_manager_instance, jp_fetch):
fs_manager = fs_manager_instance
remote_fs_info = fs_manager.get_filesystem("TestSourceAWS")
remote_key = remote_fs_info["key"]
remote_fs = remote_fs_info["info"]["instance"]
remote_root_path = remote_fs_info["info"]["path"]
remote_key = "TestSourceAWS"
remote_fs_info = fs_manager.get_filesystem(remote_key)
remote_fs = remote_fs_info["instance"]
remote_root_path = remote_fs_info["path"]
assert remote_fs is not None

local_fs_info = fs_manager.get_filesystem("TestDir")
local_key = local_fs_info["key"]
local_fs = local_fs_info["info"]["instance"]
local_root_path = local_fs_info["info"]["path"]
local_key = "TestDir"
local_fs_info = fs_manager.get_filesystem(local_key)
local_fs = local_fs_info["instance"]
local_root_path = local_fs_info["path"]
assert local_fs is not None

# upload file [local to remote]
Expand Down

0 comments on commit 76d8a78

Please sign in to comment.