diff options
author | Robey Pointer <robey@lag.net> | 2004-05-29 18:58:11 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-05-29 18:58:11 +0000 |
commit | 4d30633457015d53baebb95d3945e1e72618e85a (patch) | |
tree | b02c8f950fae4c262dc396d4854a0db6ec964eea /tests/test_sftp.py | |
parent | af8cfeced90cd1b9630b262b18d0b8773dade491 (diff) |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-55]
add an sftp unit test for making 100 files
create 100 files on the remote server, set their mode with chmod, then verify
that they're all there and contain the right data. valeriy is reporting that
sometimes he's getting stuck after 20 and though i'm not seeing it, i want to
add a test to try to pin it down.
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-x | tests/test_sftp.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 5085d7a1..b5145eaa 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -26,6 +26,7 @@ do test file operations in (so no existing files will be harmed). """ import sys, os +import random # need a host and private-key where we have acecss HOST = os.environ.get('TEST_HOST', 'localhost') @@ -307,3 +308,32 @@ class SFTPTest (unittest.TestCase): sftp.remove(FOLDER + '/original.txt') except: pass + + def test_A_lots_of_files(self): + """ + create a bunch of files over the same session. + """ + numfiles = 100 + try: + for i in range(numfiles): + f = sftp.open('%s/file%d.txt' % (FOLDER, i), 'w', 1) + f.write('this is file #%d.\n' % i) + f.close() + sftp.chmod('%s/file%d.txt' % (FOLDER, i), 0660) + + # now make sure every file is there, by creating a list of filenmes + # and reading them in random order. + numlist = range(numfiles) + while len(numlist) > 0: + r = numlist[random.randint(0, len(numlist) - 1)] + print r, + f = sftp.open('%s/file%d.txt' % (FOLDER, r)) + self.assertEqual(f.readline(), 'this is file #%d.\n' % r) + f.close() + numlist.remove(r) + finally: + for i in range(numfiles): + try: + sftp.remove('%s/file%d.txt' % (FOLDER, i)) + except: + pass |