Skip to content

Commit

Permalink
feat: remove duplicate test and add test for removed dir for complete…
Browse files Browse the repository at this point in the history
…ness
  • Loading branch information
hlouzada committed Jan 25, 2025
1 parent d992819 commit de87c4d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions spyder/plugins/remoteclient/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from spyder.api.asyncdispatcher import AsyncDispatcher
from spyder.plugins.remoteclient.plugin import RemoteClient
from spyder.plugins.remoteclient.api.modules.file_services import RemoteOSError


class TestRemoteFilesAPI:
Expand All @@ -32,19 +33,6 @@ async def test_create_dir(
"success": True
}

@AsyncDispatcher.dispatch(early_return=False)
async def test_list_dir(
self,
remote_client: RemoteClient,
remote_client_id: str,
):
"""Test that a directory can be listed on the remote server."""
file_api_class = remote_client.get_file_api(remote_client_id)
assert file_api_class is not None

async with file_api_class() as file_api:
assert await file_api.ls(self.remote_temp_dir) == []

@AsyncDispatcher.dispatch(early_return=False)
async def test_write_file(
self,
Expand Down Expand Up @@ -147,6 +135,21 @@ async def test_rm_dir(
"success": True
}

@AsyncDispatcher.dispatch(early_return=False)
async def test_ls_nonexistent_dir(
self,
remote_client: RemoteClient,
remote_client_id: str,
):
"""Test that listing a nonexistent directory raises an error."""
file_api_class = remote_client.get_file_api(remote_client_id)
assert file_api_class is not None

async with file_api_class() as file_api:
with pytest.raises(RemoteOSError) as exc_info:
await file_api.ls(self.remote_temp_dir)

assert exc_info.value.errno == 2 # ENOENT: No such file or directory

if __name__ == "__main__":
pytest.main()

0 comments on commit de87c4d

Please sign in to comment.