Skip to content

Commit

Permalink
test_fs: Add new tests
Browse files Browse the repository at this point in the history
`test_listdir_non_exists`
`test_push_pull_with_different_sizes`
  • Loading branch information
netanelc305 committed Dec 24, 2023
1 parent 9b6ee75 commit 23952d7
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/rpcclient/tests/test_fs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from pathlib import Path
from stat import S_IMODE

import pytest

from rpcclient.darwin.consts import UF_IMMUTABLE
from rpcclient.exceptions import RpcPermissionError
from rpcclient.exceptions import RpcFileNotFoundError, RpcPermissionError


def test_chown(client, tmp_path):
Expand Down Expand Up @@ -66,6 +67,29 @@ def test_listdir(client, tmp_path):
assert client.fs.listdir(tmp_path) == ['temp.txt']


def test_listdir_non_exists(client):
with pytest.raises(RpcFileNotFoundError):
client.fs.listdir('/non_exists_path')


@pytest.mark.parametrize('file_size', [1024, 10240, 102400])
def test_push_pull_with_different_sizes(client, tmp_path, file_size):
assert not client.fs.listdir(tmp_path)
local = Path('/tmp/temp.bin')
local_pull = Path('/tmp/temp2.bin')
remote = tmp_path / 'temp.bin'

with open(local, 'wb') as f:
f.write(b'\0' * file_size)

client.fs.push(local, remote)
assert client.fs.lstat(remote).st_size == file_size
client.fs.pull(remote, local_pull)
assert local_pull.stat().st_size == file_size
local.unlink(missing_ok=True)
local_pull.unlink(missing_ok=True)


def test_scandir_sanity(client, tmp_path):
entries = [e for e in client.fs.scandir(tmp_path)]
assert not entries
Expand Down

0 comments on commit 23952d7

Please sign in to comment.