Back to index

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

List of all members.

Public Member Functions

def test_compare_empties
def test_compare_identical
def test_compare_changed_file
def test_compare_changed_file_ignore_blanks
def test_compare_changed_file_explicit_skip
def test_compare_changed_file_implicit_skip
def test_compare_added_file_no_missing_as_empty
def test_compare_added_file_missing_as_empty
def test_compare_removed_file_no_missing_as_empty
def test_compare_removed_file_missing_as_empty

Static Public Attributes

 site = None
 tool = None

Private Member Functions

def _getTargetClass
def _makeOne
def _makeSite
def _makeContext
def _makeDirectory
def _makeFile

Detailed Description

Definition at line 96 of file test_differ.py.


Member Function Documentation

Definition at line 101 of file test_differ.py.

00101 
00102     def _getTargetClass( self ):
00103 
00104         from Products.GenericSetup.differ import ConfigDiff
00105         return ConfigDiff

def GenericSetup.tests.test_differ.ConfigDiffTests._makeContext (   self,
  context_id 
) [private]

Definition at line 121 of file test_differ.py.

00121 
00122     def _makeContext( self, context_id ):
00123 
00124         from Products.GenericSetup.context import SnapshotImportContext
00125 
00126         self._makeSite()
00127 
00128         if context_id not in self.tool.snapshots.objectIds():
00129             self.tool.snapshots._setObject( context_id, Folder( context_id ) )
00130 
00131         ctx = SnapshotImportContext( self.tool, context_id )
00132 
00133         return ctx.__of__( self.tool )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tests.test_differ.ConfigDiffTests._makeDirectory (   self,
  snapshot_id,
  subdir 
) [private]

Definition at line 134 of file test_differ.py.

00134 
00135     def _makeDirectory( self, snapshot_id, subdir ):
00136 
00137         self._makeSite()
00138         folder = self.tool.snapshots._getOb( snapshot_id )
00139 
00140         for element in subdir.split( '/' ):
00141 
00142             try:
00143                 folder = folder._getOb( element )
00144             except AttributeError:
00145                 folder._setObject( element, Folder( element ) )
00146                 folder = folder._getOb( element )
00147 
00148         return folder

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tests.test_differ.ConfigDiffTests._makeFile (   self,
  snapshot_id,
  filename,
  contents,
  content_type = 'text/plain',
  mod_time = None,
  subdir = None 
) [private]

Definition at line 156 of file test_differ.py.

00156 
00157                  ):
00158 
00159         self._makeSite()
00160         snapshots = self.tool.snapshots
00161         snapshot = snapshots._getOb( snapshot_id )
00162 
00163         if subdir is not None:
00164             folder = self._makeDirectory( snapshot_id, subdir )
00165         else:
00166             folder = snapshot
00167 
00168         file = File( filename, '', contents, content_type )
00169         folder._setObject( filename, file )
00170 
00171         if mod_time is not None:
00172 
00173             def __faux_mod_time():
00174                 return mod_time
00175 
00176             folder.bobobase_modification_time = \
00177             file.bobobase_modification_time = __faux_mod_time
00178 
00179         return folder._getOb( filename )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tests.test_differ.ConfigDiffTests._makeOne (   self,
  lhs,
  rhs,
  args,
  kw 
) [private]

Definition at line 106 of file test_differ.py.

00106 
00107     def _makeOne( self, lhs, rhs, *args, **kw ):
00108 
00109         return self._getTargetClass()( lhs, rhs, *args, **kw )

Definition at line 110 of file test_differ.py.

00110 
00111     def _makeSite( self ):
00112 
00113         if self.site is not None:
00114             return
00115 
00116         site = self.site = DummySite('site').__of__(self.app)
00117         site._setObject( 'setup_tool', Folder( 'setup_tool' ) )
00118         self.tool = tool = site._getOb( 'setup_tool' )
00119 
00120         tool._setObject( 'snapshots', Folder( 'snapshots' ) )

Here is the caller graph for this function:

Definition at line 304 of file test_differ.py.

00304 
00305     def test_compare_added_file_missing_as_empty( self ):
00306 
00307         AFTER = DateTime( '2004-02-29T23:59:59Z' )
00308         lhs = self._makeContext( 'lhs' )
00309         rhs = self._makeContext( 'rhs' )
00310 
00311         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ' )
00312         self._makeDirectory( 'lhs', subdir='sub' )
00313         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nWXYZ' )
00314         self._makeFile( 'rhs', 'again.txt', 'GHIJKL', subdir='sub'
00315                       , mod_time=AFTER )
00316 
00317         cd = self._makeOne( lhs, rhs, missing_as_empty=True )
00318 
00319         diffs = cd.compare()
00320 
00321         self.assertEqual( diffs, ADDED_FILE_DIFFS_MAE % AFTER )

Definition at line 288 of file test_differ.py.

00288 
00289     def test_compare_added_file_no_missing_as_empty( self ):
00290 
00291         lhs = self._makeContext( 'lhs' )
00292         rhs = self._makeContext( 'rhs' )
00293 
00294         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ' )
00295         self._makeDirectory( 'lhs', subdir='sub' )
00296         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nWXYZ' )
00297         self._makeFile( 'rhs', 'again.txt', 'GHIJKL', subdir='sub' )
00298 
00299         cd = self._makeOne( lhs, rhs )
00300 
00301         diffs = cd.compare()
00302 
00303         self.assertEqual( diffs, ADDED_FILE_DIFFS_NO_MAE )

Definition at line 207 of file test_differ.py.

00207 
00208     def test_compare_changed_file( self ):
00209 
00210         BEFORE = DateTime( '2004-01-01T00:00:00Z' )
00211         AFTER = DateTime( '2004-02-29T23:59:59Z' )
00212 
00213         lhs = self._makeContext( 'lhs' )
00214         rhs = self._makeContext( 'rhs' )
00215 
00216         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ', mod_time=BEFORE )
00217         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='sub' )
00218         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nQRST', mod_time=AFTER )
00219         self._makeFile( 'rhs', 'again.txt', 'GHIJKL', subdir='sub' )
00220 
00221         cd = self._makeOne( lhs, rhs )
00222 
00223         diffs = cd.compare()
00224 
00225         self.assertEqual( diffs, TEST_TXT_DIFFS % ( BEFORE, AFTER ) )

Definition at line 243 of file test_differ.py.

00243 
00244     def test_compare_changed_file_explicit_skip( self ):
00245 
00246         BEFORE = DateTime( '2004-01-01T00:00:00Z' )
00247         AFTER = DateTime( '2004-02-29T23:59:59Z' )
00248 
00249         lhs = self._makeContext( 'lhs' )
00250         rhs = self._makeContext( 'rhs' )
00251 
00252         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ', subdir='skipme'
00253                       , mod_time=BEFORE )
00254         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='sub' )
00255         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nQRST', subdir='skipme'
00256                       , mod_time=AFTER )
00257         self._makeFile( 'rhs', 'again.txt', 'GHIJKL', subdir='sub' )
00258 
00259         cd = self._makeOne( lhs, rhs, skip=[ 'skipme' ] )
00260 
00261         diffs = cd.compare()
00262 
00263         self.assertEqual( diffs, '' )

Definition at line 226 of file test_differ.py.

00226 
00227     def test_compare_changed_file_ignore_blanks( self ):
00228 
00229         BEFORE = DateTime( '2004-01-01T00:00:00Z' )
00230         AFTER = DateTime( '2004-02-29T23:59:59Z' )
00231 
00232         lhs = self._makeContext( 'lhs' )
00233         rhs = self._makeContext( 'rhs' )
00234 
00235         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ', mod_time=BEFORE )
00236         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\n\n\nWXYZ', mod_time=AFTER )
00237 
00238         cd = self._makeOne( lhs, rhs, ignore_blanks=True )
00239 
00240         diffs = cd.compare()
00241 
00242         self.assertEqual( diffs, '' )

Definition at line 264 of file test_differ.py.

00264 
00265     def test_compare_changed_file_implicit_skip( self ):
00266 
00267         BEFORE = DateTime( '2004-01-01T00:00:00Z' )
00268         AFTER = DateTime( '2004-02-29T23:59:59Z' )
00269 
00270         lhs = self._makeContext( 'lhs' )
00271         rhs = self._makeContext( 'rhs' )
00272 
00273         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ', subdir='CVS'
00274                       , mod_time=BEFORE )
00275         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='.svn'
00276                       , mod_time=BEFORE )
00277 
00278         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nQRST', subdir='CVS'
00279                       , mod_time=AFTER )
00280         self._makeFile( 'rhs', 'again.txt', 'MNOPQR', subdir='.svn'
00281                       , mod_time=AFTER )
00282 
00283         cd = self._makeOne( lhs, rhs )
00284 
00285         diffs = cd.compare()
00286 
00287         self.assertEqual( diffs, '' )

Definition at line 180 of file test_differ.py.

00180 
00181     def test_compare_empties( self ):
00182 
00183         lhs = self._makeContext( 'lhs' )
00184         rhs = self._makeContext( 'rhs' )
00185 
00186         cd = self._makeOne( lhs, rhs )
00187 
00188         diffs = cd.compare()
00189 
00190         self.assertEqual( diffs, '' )

Definition at line 191 of file test_differ.py.

00191 
00192     def test_compare_identical( self ):
00193 
00194         lhs = self._makeContext( 'lhs' )
00195         rhs = self._makeContext( 'rhs' )
00196 
00197         self._makeFile( 'lhs', 'test.txt', 'ABCDEF' )
00198         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='sub' )
00199         self._makeFile( 'rhs', 'test.txt', 'ABCDEF' )
00200         self._makeFile( 'rhs', 'again.txt', 'GHIJKL', subdir='sub' )
00201 
00202         cd = self._makeOne( lhs, rhs )
00203 
00204         diffs = cd.compare()
00205 
00206         self.assertEqual( diffs, '' )

Definition at line 338 of file test_differ.py.

00338 
00339     def test_compare_removed_file_missing_as_empty( self ):
00340 
00341         BEFORE = DateTime( '2004-01-01T00:00:00Z' )
00342         lhs = self._makeContext( 'lhs' )
00343         rhs = self._makeContext( 'rhs' )
00344 
00345         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ' )
00346         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='sub'
00347                       , mod_time=BEFORE )
00348         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nWXYZ' )
00349         self._makeDirectory( 'rhs', subdir='sub' )
00350 
00351         cd = self._makeOne( lhs, rhs, missing_as_empty=True )
00352 
00353         diffs = cd.compare()
00354 
00355         self.assertEqual( diffs, REMOVED_FILE_DIFFS_MAE % BEFORE )
00356 

Definition at line 322 of file test_differ.py.

00322 
00323     def test_compare_removed_file_no_missing_as_empty( self ):
00324 
00325         lhs = self._makeContext( 'lhs' )
00326         rhs = self._makeContext( 'rhs' )
00327 
00328         self._makeFile( 'lhs', 'test.txt', 'ABCDEF\nWXYZ' )
00329         self._makeFile( 'lhs', 'again.txt', 'GHIJKL', subdir='sub' )
00330         self._makeFile( 'rhs', 'test.txt', 'ABCDEF\nWXYZ' )
00331         self._makeDirectory( 'rhs', subdir='sub' )
00332 
00333         cd = self._makeOne( lhs, rhs )
00334 
00335         diffs = cd.compare()
00336 
00337         self.assertEqual( diffs, REMOVED_FILE_DIFFS_NO_MAE )


Member Data Documentation

Definition at line 98 of file test_differ.py.

Definition at line 99 of file test_differ.py.


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