Changeset 112

Show
Ignore:
Timestamp:
2002-03-30 14:53:01 (7 years ago)
Author:
schwa
Message:
MockSession.pwd: simplified implementation; now a newly introduced
    self.current_dir is returned.
MockSession.dir: path names ending with a slash now cause a dictionary
    lookup of the corresponding name without a slash.
Module: removed StatTest class because the MockSession class can be
    used instead.
Files:

Legend:

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

    r109 r112  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _mock_ftplib.py,v 1.6 2002/03/29 23:16:32 schwa Exp $ 
     32# $Id: _mock_ftplib.py,v 1.7 2002/03/30 14:53:01 schwa Exp $ 
    3333 
    3434""" 
     
    325325class MockSession: 
    326326 
    327     # used by MockSession.pwd 
    328     pwd_results = [] 
     327    # used by MockSession.cwd and MockSession.pwd 
     328    current_dir = '/home/sschwarzer' 
    329329     
    330330    # used by MockSession.dir 
    331331    dir_contents = { 
    332           '/absolute': """\ 
    333 drwxr-sr-x   2 45854    200           512 May  4  2000 path""", 
    334           '/absolute/path': """\ 
     332          '/home': """\ 
     333drwxr-sr-x   2 45854    200           512 May  4  2000 sschwarzer""", 
     334          '/home/sschwarzer': """\ 
    335335total 14 
    336336drwxr-sr-x   2 45854    200           512 May  4  2000 chemeng 
     
    354354 
    355355    def pwd(self): 
    356         result = self.pwd_results[self.pwd_result_index] 
    357         self.pwd_result_index += 1 
    358         return result 
     356        return self.current_dir 
    359357 
    360358    def dir(self, path, callback=None): 
    361359        if DEBUG: 
    362360            print 'dir: %s' % path 
     361        if path.endswith('/'): 
     362            path = path[:-1] 
    363363        if not self.dir_contents.has_key(path): 
    364364            raise ftplib.error_perm 
     
    375375        raise ftplib.error_perm 
    376376 
    377  
    378 class StatTest(MockSession): 
    379     pwd_results = ['/absolute/path'] 
    380