Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions | Static Private Attributes
GenericSetup.tests.test_context.DirectoryImportContextTests Class Reference
Inheritance diagram for GenericSetup.tests.test_context.DirectoryImportContextTests:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.tests.test_context.DirectoryImportContextTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_getLogger
def test_readDataFile_nonesuch
def test_readDataFile_simple
def test_readDataFile_subdir
def test_getLastModified_nonesuch
def test_getLastModified_simple
def test_getLastModified_subdir
def test_getLastModified_directory
def test_isDirectory_nonesuch
def test_isDirectory_simple
def test_isDirectory_nested
def test_isDirectory_directory
def test_listDirectory_nonesuch
def test_listDirectory_root
def test_listDirectory_simple
def test_listDirectory_nested
def test_listDirectory_single
def test_listDirectory_multiple
def test_listDirectory_skip_implicit
def test_listDirectory_skip_explicit

Private Member Functions

def _getTargetClass

Static Private Attributes

string _PROFILE_PATH = '/tmp/ICTTexts'

Detailed Description

Definition at line 51 of file test_context.py.


Member Function Documentation

Definition at line 55 of file test_context.py.

00055 
00056     def _getTargetClass( self ):
00057 
00058         from Products.GenericSetup.context import DirectoryImportContext
00059         return DirectoryImportContext

Definition at line 151 of file test_context.py.

00151 
00152     def test_getLastModified_directory( self ):
00153 
00154         from string import printable
00155 
00156         SUBDIR = 'subdir'
00157         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00158         fqpath = self._makeFile( FILENAME, printable )
00159         path, file = os.path.split( fqpath )
00160         timestamp = os.path.getmtime( path )
00161 
00162         site = DummySite('site').__of__(self.app)
00163         ctx = self._makeOne( site, self._PROFILE_PATH )
00164 
00165         lm = ctx.getLastModified( SUBDIR )
00166         self.failUnless( isinstance( lm, DateTime ) )
00167         self.assertEqual( lm, timestamp )

Definition at line 111 of file test_context.py.

00111 
00112     def test_getLastModified_nonesuch( self ):
00113 
00114         FILENAME = 'nonesuch.txt'
00115 
00116         site = DummySite('site').__of__(self.app)
00117         ctx = self._makeOne( site, self._PROFILE_PATH )
00118 
00119         self.assertEqual( ctx.getLastModified( FILENAME ), None )

Definition at line 120 of file test_context.py.

00120 
00121     def test_getLastModified_simple( self ):
00122 
00123         from string import printable
00124 
00125         FILENAME = 'simple.txt'
00126         fqpath = self._makeFile( FILENAME, printable )
00127         timestamp = os.path.getmtime( fqpath )
00128 
00129         site = DummySite('site').__of__(self.app)
00130         ctx = self._makeOne( site, self._PROFILE_PATH )
00131 
00132         lm = ctx.getLastModified( FILENAME )
00133         self.failUnless( isinstance( lm, DateTime ) )
00134         self.assertEqual( lm, timestamp )

Definition at line 135 of file test_context.py.

00135 
00136     def test_getLastModified_subdir( self ):
00137 
00138         from string import printable
00139 
00140         SUBDIR = 'subdir'
00141         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00142         fqpath = self._makeFile( FILENAME, printable )
00143         timestamp = os.path.getmtime( fqpath )
00144 
00145         site = DummySite('site').__of__(self.app)
00146         ctx = self._makeOne( site, self._PROFILE_PATH )
00147 
00148         lm = ctx.getLastModified( FILENAME )
00149         self.failUnless( isinstance( lm, DateTime ) )
00150         self.assertEqual( lm, timestamp )

Definition at line 60 of file test_context.py.

00060 
00061     def test_getLogger( self ):
00062 
00063         site = DummySite('site').__of__(self.app)
00064         ctx = self._makeOne( site, self._PROFILE_PATH )
00065         self.assertEqual( len( ctx.listNotes() ), 0 )
00066 
00067         logger = ctx.getLogger('foo')
00068         logger.info('bar')
00069 
00070         self.assertEqual( len( ctx.listNotes() ), 1 )
00071         level, component, message = ctx.listNotes()[0]
00072         self.assertEqual( level, logging.INFO )
00073         self.assertEqual( component, 'foo' )
00074         self.assertEqual( message, 'bar' )
00075 
00076         ctx.clearNotes()
00077         self.assertEqual( len( ctx.listNotes() ), 0 )

Definition at line 202 of file test_context.py.

00202 
00203     def test_isDirectory_directory( self ):
00204 
00205         from string import printable
00206 
00207         SUBDIR = 'subdir'
00208         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00209         fqpath = self._makeFile( FILENAME, printable )
00210 
00211         site = DummySite('site').__of__(self.app)
00212         ctx = self._makeOne( site, self._PROFILE_PATH )
00213 
00214         self.assertEqual( ctx.isDirectory( SUBDIR ), True )

Definition at line 189 of file test_context.py.

00189 
00190     def test_isDirectory_nested( self ):
00191 
00192         from string import printable
00193 
00194         SUBDIR = 'subdir'
00195         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00196         fqpath = self._makeFile( FILENAME, printable )
00197 
00198         site = DummySite('site').__of__(self.app)
00199         ctx = self._makeOne( site, self._PROFILE_PATH )
00200 
00201         self.assertEqual( ctx.isDirectory( FILENAME ), False )

Definition at line 168 of file test_context.py.

00168 
00169     def test_isDirectory_nonesuch( self ):
00170 
00171         FILENAME = 'nonesuch.txt'
00172 
00173         site = DummySite('site').__of__(self.app)
00174         ctx = self._makeOne( site, self._PROFILE_PATH )
00175 
00176         self.assertEqual( ctx.isDirectory( FILENAME ), None )

Definition at line 177 of file test_context.py.

00177 
00178     def test_isDirectory_simple( self ):
00179 
00180         from string import printable
00181 
00182         FILENAME = 'simple.txt'
00183         fqpath = self._makeFile( FILENAME, printable )
00184 
00185         site = DummySite('site').__of__(self.app)
00186         ctx = self._makeOne( site, self._PROFILE_PATH )
00187 
00188         self.assertEqual( ctx.isDirectory( FILENAME ), False )

Definition at line 277 of file test_context.py.

00277 
00278     def test_listDirectory_multiple( self ):
00279 
00280         from string import printable
00281         SUBDIR = 'subdir'
00282         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00283         self._makeFile( FILENAME, printable )
00284         self._makeFile( os.path.join( SUBDIR, 'another.txt' ), 'ABC' )
00285 
00286         site = DummySite('site').__of__(self.app)
00287         ctx = self._makeOne( site, self._PROFILE_PATH )
00288 
00289         names = ctx.listDirectory( SUBDIR )
00290         self.assertEqual( len( names ), 2 )
00291         self.failUnless( 'nested.txt' in names )
00292         self.failUnless( 'another.txt' in names )

Definition at line 249 of file test_context.py.

00249 
00250     def test_listDirectory_nested( self ):
00251 
00252         from string import printable
00253 
00254         SUBDIR = 'subdir'
00255         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00256         self._makeFile( FILENAME, printable )
00257 
00258         site = DummySite('site').__of__(self.app)
00259         ctx = self._makeOne( site, self._PROFILE_PATH )
00260 
00261         self.assertEqual( ctx.listDirectory( FILENAME ), None )

Definition at line 215 of file test_context.py.

00215 
00216     def test_listDirectory_nonesuch( self ):
00217 
00218         FILENAME = 'nonesuch.txt'
00219 
00220         site = DummySite('site').__of__(self.app)
00221         ctx = self._makeOne( site, self._PROFILE_PATH )
00222 
00223         self.assertEqual( ctx.listDirectory( FILENAME ), None )

Definition at line 224 of file test_context.py.

00224 
00225     def test_listDirectory_root( self ):
00226 
00227         from string import printable
00228 
00229         site = DummySite('site').__of__(self.app)
00230         ctx = self._makeOne( site, self._PROFILE_PATH )
00231 
00232         FILENAME = 'simple.txt'
00233         self._makeFile( FILENAME, printable )
00234 
00235         self.assertEqual( len( ctx.listDirectory( None ) ), 1 )
00236         self.failUnless( FILENAME in ctx.listDirectory( None ) )

Definition at line 237 of file test_context.py.

00237 
00238     def test_listDirectory_simple( self ):
00239 
00240         from string import printable
00241 
00242         FILENAME = 'simple.txt'
00243         self._makeFile( FILENAME, printable )
00244 
00245         site = DummySite('site').__of__(self.app)
00246         ctx = self._makeOne( site, self._PROFILE_PATH )
00247 
00248         self.assertEqual( ctx.listDirectory( FILENAME ), None )

Definition at line 262 of file test_context.py.

00262 
00263     def test_listDirectory_single( self ):
00264 
00265         from string import printable
00266 
00267         SUBDIR = 'subdir'
00268         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00269         self._makeFile( FILENAME, printable )
00270 
00271         site = DummySite('site').__of__(self.app)
00272         ctx = self._makeOne( site, self._PROFILE_PATH )
00273 
00274         names = ctx.listDirectory( SUBDIR )
00275         self.assertEqual( len( names ), 1 )
00276         self.failUnless( 'nested.txt' in names )

Definition at line 315 of file test_context.py.

00315 
00316     def test_listDirectory_skip_explicit( self ):
00317 
00318         from string import printable
00319         SUBDIR = 'subdir'
00320         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00321         self._makeFile( FILENAME, printable )
00322         self._makeFile( os.path.join( SUBDIR, 'another.txt' ), 'ABC' )
00323         self._makeFile( os.path.join( SUBDIR, 'another.bak' ), '123' )
00324         self._makeFile( os.path.join( SUBDIR, 'CVS/skip.txt' ), 'DEF' )
00325         self._makeFile( os.path.join( SUBDIR, '.svn/skip.txt' ), 'GHI' )
00326 
00327         site = DummySite('site').__of__(self.app)
00328         ctx = self._makeOne( site, self._PROFILE_PATH )
00329 
00330         names = ctx.listDirectory(SUBDIR, skip=('nested.txt',),
00331                                   skip_suffixes=('.bak',))
00332         self.assertEqual( len( names ), 3 )
00333         self.failIf( 'nested.txt' in names )
00334         self.failIf( 'nested.bak' in names )
00335         self.failUnless( 'another.txt' in names )
00336         self.failUnless( 'CVS' in names )
00337         self.failUnless( '.svn' in names )
00338 

Definition at line 293 of file test_context.py.

00293 
00294     def test_listDirectory_skip_implicit( self ):
00295 
00296         from string import printable
00297         SUBDIR = 'subdir'
00298         FILENAME = os.path.join( SUBDIR, 'nested.txt' )
00299         self._makeFile( FILENAME, printable )
00300         self._makeFile( os.path.join( SUBDIR, 'another.txt' ), 'ABC' )
00301         self._makeFile( os.path.join( SUBDIR, 'another.txt~' ), '123' )
00302         self._makeFile( os.path.join( SUBDIR, 'CVS/skip.txt' ), 'DEF' )
00303         self._makeFile( os.path.join( SUBDIR, '.svn/skip.txt' ), 'GHI' )
00304 
00305         site = DummySite('site').__of__(self.app)
00306         ctx = self._makeOne( site, self._PROFILE_PATH )
00307 
00308         names = ctx.listDirectory( SUBDIR )
00309         self.assertEqual( len( names ), 2 )
00310         self.failUnless( 'nested.txt' in names )
00311         self.failUnless( 'another.txt' in names )
00312         self.failIf( 'another.txt~' in names )
00313         self.failIf( 'CVS' in names )
00314         self.failIf( '.svn' in names )

Definition at line 78 of file test_context.py.

00078 
00079     def test_readDataFile_nonesuch( self ):
00080 
00081         FILENAME = 'nonesuch.txt'
00082 
00083         site = DummySite('site').__of__(self.app)
00084         ctx = self._makeOne( site, self._PROFILE_PATH )
00085 
00086         self.assertEqual( ctx.readDataFile( FILENAME ), None )

Definition at line 87 of file test_context.py.

00087 
00088     def test_readDataFile_simple( self ):
00089 
00090         from string import printable
00091 
00092         FILENAME = 'simple.txt'
00093         self._makeFile( FILENAME, printable )
00094 
00095         site = DummySite('site').__of__(self.app)
00096         ctx = self._makeOne( site, self._PROFILE_PATH )
00097 
00098         self.assertEqual( ctx.readDataFile( FILENAME ), printable )

Definition at line 99 of file test_context.py.

00099 
00100     def test_readDataFile_subdir( self ):
00101 
00102         from string import printable
00103 
00104         FILENAME = 'subdir/nested.txt'
00105         self._makeFile( FILENAME, printable )
00106 
00107         site = DummySite('site').__of__(self.app)
00108         ctx = self._makeOne( site, self._PROFILE_PATH )
00109 
00110         self.assertEqual( ctx.readDataFile( FILENAME ), printable )


Member Data Documentation

Definition at line 53 of file test_context.py.


The documentation for this class was generated from the following file: