| 100 | | # class TestPath(Base): |
|---|
| 101 | | # """Test operations in FTPHost.path.""" |
|---|
| 102 | | # |
|---|
| 103 | | # def test_isdir_isfile_islink(self): |
|---|
| 104 | | # """Test FTPHost._Path.isdir/isfile/islink.""" |
|---|
| 105 | | # host = self.host |
|---|
| 106 | | # host.chdir(self.testdir) |
|---|
| 107 | | # # test a path which isn't there |
|---|
| 108 | | # self.failIf( host.path.isdir('notthere') ) |
|---|
| 109 | | # self.failIf( host.path.isfile('notthere') ) |
|---|
| 110 | | # self.failIf( host.path.islink('notthere') ) |
|---|
| 111 | | # # test a directory |
|---|
| 112 | | # self.failUnless( host.path.isdir(self.testdir) ) |
|---|
| 113 | | # self.failIf( host.path.isfile(self.testdir) ) |
|---|
| 114 | | # self.failIf( host.path.islink(self.testdir) ) |
|---|
| 115 | | # # test a file |
|---|
| 116 | | # host.upload('ftputil.py', 'ftputil2.py', 'b') |
|---|
| 117 | | # self.failIf( host.path.isdir('ftputil2.py') ) |
|---|
| 118 | | # self.failUnless( host.path.isfile('ftputil2.py') ) |
|---|
| 119 | | # self.failIf( host.path.islink(self.testdir) ) |
|---|
| 120 | | # # clean up |
|---|
| 121 | | # host.remove('ftputil2.py') |
|---|
| 122 | | # host.chdir(self.rootdir) |
|---|
| 123 | | # |
|---|
| 124 | | # def test_getmtime(self): |
|---|
| 125 | | # """Test FTPHost._Path.getmtime.""" |
|---|
| 126 | | # host = self.host |
|---|
| 127 | | # host.chdir(self.testdir) |
|---|
| 128 | | # # test a directory |
|---|
| 129 | | # local_time = time.time() |
|---|
| 130 | | # host.mkdir('__test2') |
|---|
| 131 | | # remote_mtime = host.path.getmtime('__test2') |
|---|
| 132 | | # # accept a difference of up to 30 seconds |
|---|
| 133 | | # self.failIf(remote_mtime - local_time >= 30) |
|---|
| 134 | | # # test a file |
|---|
| 135 | | # local_time = time.time() |
|---|
| 136 | | # host.upload('ftputil.py', 'ftputil2.py', 'b') |
|---|
| 137 | | # remote_mtime = host.path.getmtime('ftputil2.py') |
|---|
| 138 | | # # accept a difference of up to 30 seconds |
|---|
| 139 | | # self.failIf(remote_mtime - local_time >= 30) |
|---|
| 140 | | # # clean up |
|---|
| 141 | | # host.rmdir('__test2') |
|---|
| 142 | | # host.remove('ftputil2.py') |
|---|
| 143 | | # host.chdir(self.rootdir) |
|---|
| 144 | | # |
|---|
| 145 | | # def test_getsize(self): |
|---|
| 146 | | # """Test FTPHost._Path.getsize.""" |
|---|
| 147 | | # host = self.host |
|---|
| 148 | | # host.chdir(self.testdir) |
|---|
| 149 | | # # test a directory |
|---|
| 150 | | # host.mkdir('__test2') |
|---|
| 151 | | # remote_size = host.path.getsize('__test2') |
|---|
| 152 | | # empty_dir_size = 512 |
|---|
| 153 | | # self.assertEqual(remote_size, empty_dir_size) |
|---|
| 154 | | # # test a file |
|---|
| 155 | | # host.upload('ftputil.py', 'ftputil2.py', 'b') |
|---|
| 156 | | # local_size = os.path.getsize('ftputil.py') |
|---|
| 157 | | # remote_size = host.path.getsize('ftputil2.py') |
|---|
| 158 | | # self.assertEqual(local_size, remote_size) |
|---|
| 159 | | # # clean up |
|---|
| 160 | | # host.rmdir('__test2') |
|---|
| 161 | | # host.remove('ftputil2.py') |
|---|
| 162 | | # host.chdir(self.rootdir) |
|---|
| 163 | | # |
|---|
| 164 | | # |
|---|
| | 97 | class TestPath(unittest.TestCase): |
|---|
| | 98 | """Test operations in FTPHost.path.""" |
|---|
| | 99 | |
|---|
| | 100 | def test_isdir_isfile_islink(self): |
|---|
| | 101 | """Test FTPHost._Path.isdir/isfile/islink.""" |
|---|
| | 102 | testdir = '/home/sschwarzer' |
|---|
| | 103 | host = FTPHostWrapper(_mock_ftplib.MockSession) |
|---|
| | 104 | host.chdir(testdir) |
|---|
| | 105 | # test a path which isn't there |
|---|
| | 106 | self.failIf( host.path.isdir('notthere') ) |
|---|
| | 107 | self.failIf( host.path.isfile('notthere') ) |
|---|
| | 108 | self.failIf( host.path.islink('notthere') ) |
|---|
| | 109 | # test a directory |
|---|
| | 110 | self.failUnless( host.path.isdir(testdir) ) |
|---|
| | 111 | self.failIf( host.path.isfile(testdir) ) |
|---|
| | 112 | self.failIf( host.path.islink(testdir) ) |
|---|
| | 113 | # test a file |
|---|
| | 114 | testfile = '/home/sschwarzer/index.html' |
|---|
| | 115 | self.failIf( host.path.isdir(testfile) ) |
|---|
| | 116 | self.failUnless( host.path.isfile(testfile) ) |
|---|
| | 117 | self.failIf( host.path.islink(testfile) ) |
|---|
| | 118 | # test a link |
|---|
| | 119 | testlink = '/home/sschwarzer/osup' |
|---|
| | 120 | # uncomment these two when following links is implemented |
|---|
| | 121 | #self.failIf( host.path.isdir(testlink) ) |
|---|
| | 122 | #self.failIf( host.path.isfile(testlink) ) |
|---|
| | 123 | self.failUnless( host.path.islink(testlink) ) |
|---|
| | 124 | |
|---|
| | 125 | |
|---|