Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RemoteOperations::path_exists is updated#206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -247,8 +247,30 @@ def listdir(self, path):
return result.splitlines()

def path_exists(self, path):
result = self.exec_command("test -e {}; echo $?".format(path), encoding=get_default_encoding())
return int(result.strip()) == 0
command = ["test", "-e", path]

exit_status, output, error = self.exec_command(cmd=command, encoding=get_default_encoding(), ignore_errors=True, verbose=True)

assert type(output) == str # noqa: E721
assert type(error) == str # noqa: E721

if exit_status == 0:
return True

if exit_status == 1:
return False

errMsg = "Test operation returns an unknown result code: {0}. Path is [{1}].".format(
exit_status,
path)

RaiseError.CommandExecutionError(
cmd=command,
exit_code=exit_status,
msg_arg=errMsg,
error=error,
out=output
)

@property
def pathsep(self):
Expand Down
26 changes: 16 additions & 10 deletionstests/test_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -130,23 +130,29 @@ def test_listdir(self):

assert isinstance(files, list)

deftest_path_exists_true(self):
deftest_path_exists_true__directory(self):
"""
Test path_exists for an existingpath.
Test path_exists for an existingdirectory.
"""
path = "/etc"
response = self.operations.path_exists(path)
assert self.operations.path_exists("/etc") is True

assert response is True
def test_path_exists_true__file(self):
"""
Test path_exists for an existing file.
"""
assert self.operations.path_exists(__file__) is True

deftest_path_exists_false(self):
deftest_path_exists_false__directory(self):
"""
Test path_exists for a non-existingpath.
Test path_exists for a non-existingdirectory.
"""
path = "/nonexistent_path"
response = self.operations.path_exists(path)
assert self.operations.path_exists("/nonexistent_path") is False

assert response is False
def test_path_exists_false__file(self):
"""
Test path_exists for a non-existing file.
"""
assert self.operations.path_exists("/etc/nonexistent_path.txt") is False

def test_write_text_file(self):
"""
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp