Skip to content

OsOperations.isdir is added #166

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions testgres/operations/os_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def read_binary(self, filename, start_pos):
def isfile(self, remote_file):
raise NotImplementedError()

def isdir(self, dirname):
raise NotImplementedError()

def get_file_size(self, filename):
raise NotImplementedError()

Expand Down
64 changes: 64 additions & 0 deletions tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,67 @@ def test_get_file_size__unk_file(self):

with pytest.raises(FileNotFoundError, match=re.escape("[Errno 2] No such file or directory: '/dummy'")):
self.operations.get_file_size("/dummy")

def test_isfile_true(self):
"""
Test isfile for an existing file.
"""
filename = __file__

response = self.operations.isfile(filename)

assert response is True

def test_isfile_false__not_exist(self):
"""
Test isfile for a non-existing file.
"""
filename = os.path.join(os.path.dirname(__file__), "nonexistent_file.txt")

response = self.operations.isfile(filename)

assert response is False

def test_isfile_false__directory(self):
"""
Test isfile for a firectory.
"""
name = os.path.dirname(__file__)

assert self.operations.isdir(name)

response = self.operations.isfile(name)

assert response is False

def test_isdir_true(self):
"""
Test isdir for an existing directory.
"""
name = os.path.dirname(__file__)

response = self.operations.isdir(name)

assert response is True

def test_isdir_false__not_exist(self):
"""
Test isdir for a non-existing directory.
"""
name = os.path.join(os.path.dirname(__file__), "it_is_nonexistent_directory")

response = self.operations.isdir(name)

assert response is False

def test_isdir_false__file(self):
"""
Test isdir for a file.
"""
name = __file__

assert self.operations.isfile(name)

response = self.operations.isdir(name)

assert response is False
50 changes: 47 additions & 3 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,62 @@ def test_isfile_true(self):
"""
Test isfile for an existing file.
"""
filename = "/etc/hosts"
filename = __file__

response = self.operations.isfile(filename)

assert response is True

def test_isfile_false(self):
def test_isfile_false__not_exist(self):
"""
Test isfile for a non-existing file.
"""
filename = "/nonexistent_file.txt"
filename = os.path.join(os.path.dirname(__file__), "nonexistent_file.txt")

response = self.operations.isfile(filename)

assert response is False

def test_isfile_false__directory(self):
"""
Test isfile for a firectory.
"""
name = os.path.dirname(__file__)

assert self.operations.isdir(name)

response = self.operations.isfile(name)

assert response is False

def test_isdir_true(self):
"""
Test isdir for an existing directory.
"""
name = os.path.dirname(__file__)

response = self.operations.isdir(name)

assert response is True

def test_isdir_false__not_exist(self):
"""
Test isdir for a non-existing directory.
"""
name = os.path.join(os.path.dirname(__file__), "it_is_nonexistent_directory")

response = self.operations.isdir(name)

assert response is False

def test_isdir_false__file(self):
"""
Test isdir for a file.
"""
name = __file__

assert self.operations.isfile(name)

response = self.operations.isdir(name)

assert response is False