Changeset 161

Show
Ignore:
Timestamp:
2002-04-01 15:06:36 (7 years ago)
Author:
schwa
Message:
TestStat: added method test_stat_following_link.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/_test_ftputil.py

    r157 r161  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _test_ftputil.py,v 1.57 2002/04/01 13:58:28 schwa Exp $ 
     32# $Id: _test_ftputil.py,v 1.58 2002/04/01 15:06:36 schwa Exp $ 
    3333 
    3434import unittest 
     
    151151        self.assertEqual( oct(stat_result.st_mode), '0100644' ) 
    152152        self.assertEqual(stat_result.st_size, 4604) 
    153         self.assertEqual(stat_result.st_name, 'index.html') 
    154         self.assertEqual(stat_result.st_target, None) 
    155153 
    156154    def test_lstat_one_dir(self): 
     
    168166        self.assertEqual(stat_result.st_mtime, 937785600.0) 
    169167        self.assertEqual(stat_result.st_ctime, None) 
    170         self.assertEqual(stat_result.st_name, 'scios2') 
    171         self.assertEqual(stat_result.st_target, None
     168        self.assertEqual( stat_result, (17901, None, None, 6, '45854', '200', 
     169                                        512, None, 937785600.0, None)
    172170 
    173171    def test_lstat_via_stat_module(self): 
     
    177175        self.failUnless( stat.S_ISDIR(stat_result.st_mode) ) 
    178176 
    179 #     def test_stat_following_link(self): 
    180 #         """Test stat when invoked on a link.""" 
    181 #         host = ftp_host_factory() 
    182 #         stat_result = host.lstat('/home/a_link') 
    183 #         self.failUnless(stat_result.st_name,  
     177    def test_stat_following_link(self): 
     178        """Test stat when invoked on a link.""" 
     179        host = ftp_host_factory() 
     180        # simple link 
     181        stat_result = host.stat('/home/link') 
     182        self.assertEqual(stat_result.st_size, 4604) 
     183        # link pointing to a link 
     184        stat_result = host.stat('/home/python/link_link') 
     185        self.assertEqual(stat_result.st_size, 4604) 
     186        stat_result = host.stat('../python/link_link') 
     187        self.assertEqual(stat_result.st_size, 4604) 
     188        # recursive link structures 
     189        self.assertRaises(ftputil.PermanentError, host.stat, 
     190                          '../python/bad_link') 
     191        self.assertRaises(ftputil.PermanentError, host.stat, 
     192                          '/home/bad_link') 
     193 
    184194 
    185195class TestListdir(unittest.TestCase): 
     
    228238        # test a link 
    229239        testlink = '/home/sschwarzer/osup' 
    230         #XXX uncomment these two when following links is implemented 
    231         #self.failIf( host.path.isdir(testlink) ) 
    232         #self.failIf( host.path.isfile(testlink) ) 
     240        self.failIf( host.path.isdir(testlink) ) 
     241        self.failIf( host.path.isfile(testlink) ) 
    233242        self.failUnless( host.path.islink(testlink) ) 
    234243