diff options
Diffstat (limited to 'tests/stub_sftp.py')
-rw-r--r-- | tests/stub_sftp.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py index 06ceb419..13e7f3b4 100644 --- a/tests/stub_sftp.py +++ b/tests/stub_sftp.py @@ -30,6 +30,7 @@ from paramiko import ( SFTPAttributes, SFTPHandle, SFTP_OK, + SFTP_FAILURE, AUTH_SUCCESSFUL, OPEN_SUCCEEDED, ) @@ -150,12 +151,24 @@ class StubSFTPServer(SFTPServerInterface): def rename(self, oldpath, newpath): oldpath = self._realpath(oldpath) newpath = self._realpath(newpath) + if os.path.exists(newpath): + return SFTP_FAILURE try: os.rename(oldpath, newpath) except OSError as e: return SFTPServer.convert_errno(e.errno) return SFTP_OK + def posix_rename(self, oldpath, newpath): + oldpath = self._realpath(oldpath) + newpath = self._realpath(newpath) + try: + os.rename(oldpath, newpath) + except OSError as e: + return SFTPServer.convert_errno(e.errno) + return SFTP_OK + + def mkdir(self, path, attr): path = self._realpath(path) try: |