summaryrefslogtreecommitdiff
path: root/tests/test_sftp.py
diff options
context:
space:
mode:
authorMika Pflüger <Mika Pflüger mika@mikapflueger.de>2015-01-06 20:01:26 +0100
committerMika Pflüger <Mika Pflüger mika@mikapflueger.de>2015-01-06 20:20:23 +0100
commit46efa38fc1ee218789593c8a26b5d70c2c22d5a3 (patch)
tree8cc75b649ba67309f57f44b87ce388a03c4c5f76 /tests/test_sftp.py
parente2aeeed2c5feeaab4e8eab1adc614b2be21ab320 (diff)
downloadparamiko-46efa38fc1ee218789593c8a26b5d70c2c22d5a3.tar.gz
Add test for posix-rename@openssh.com extension for SFTP client
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-xtests/test_sftp.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index cb8f7f84..2b86dec3 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -276,6 +276,39 @@ class SFTPTest (unittest.TestCase):
except:
pass
+
+ def test_5a_posix_rename(self):
+ """Test posix-rename@openssh.com protocol extension."""
+ try:
+ # first check that the normal rename works as specified
+ with sftp.open(FOLDER + '/a', 'w') as f:
+ f.write('one')
+ sftp.rename(FOLDER + '/a', FOLDER + '/b')
+ with sftp.open(FOLDER + '/a', 'w') as f:
+ f.write('two')
+ try:
+ sftp.rename(FOLDER + '/a', FOLDER + '/b')
+ self.assertTrue(False, 'no exception when rename-ing onto existing file')
+ except OSError:
+ pass
+
+ # now check with the posix_rename
+ sftp.posix_rename(FOLDER + '/a', FOLDER + '/b')
+ with sftp.open(FOLDER + '/b', 'r') as f:
+ data = u(f.read())
+ self.assertEqual('two', data, "Contents of renamed file not the same as original file")
+
+ finally:
+ try:
+ sftp.remove(FOLDER + '/a')
+ except:
+ pass
+ try:
+ sftp.remove(FOLDER + '/b')
+ except:
+ pass
+
+
def test_6_folder(self):
"""
create a temporary folder, verify that we can create a file in it, then