Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFCore.exportimport.tests.test_content.SiteStructureExporterTests Class Reference

List of all members.

Public Member Functions

def tearDown
def test_export_empty_site
def test_export_empty_site_with_setup_tool
def test_export_site_with_non_exportable_simple_items
def test_export_site_with_exportable_simple_items
def test_export_site_with_subfolders
def test_export_site_with_csvaware
def test_import_empty_site
def test_import_empty_site_with_setup_tool
def test_import_site_with_subfolders
def test_import_site_with_subitems
def test_import_site_with_subitems_and_blanklines_dotobjects
def test_import_site_with_subitem_unknown_portal_type
def test_reimport_no_structure_no_delete
def test_reimport_with_structure_does_delete
def test_reimport_with_structure_and_preserve
def test_reimport_with_structure_and_preserve_partial
def test_reimport_with_structure_partial_preserve_and_delete
def test_import_site_with_subfolders_and_preserve

Private Member Functions

def _getExporter
def _getImporter
def _makeSetupTool
def _setUpAdapters

Detailed Description

Definition at line 31 of file test_content.py.


Member Function Documentation

Definition at line 33 of file test_content.py.

00033 
00034     def _getExporter(self):
00035         from Products.CMFCore.exportimport.content import exportSiteStructure
00036         return exportSiteStructure

Here is the caller graph for this function:

Definition at line 37 of file test_content.py.

00037 
00038     def _getImporter(self):
00039         from Products.CMFCore.exportimport.content import importSiteStructure
00040         return importSiteStructure

Here is the caller graph for this function:

Definition at line 41 of file test_content.py.

00041 
00042     def _makeSetupTool(self):
00043         from Products.GenericSetup.tool import SetupTool
00044         return SetupTool('portal_setup')

Here is the caller graph for this function:

Definition at line 45 of file test_content.py.

00045 
00046     def _setUpAdapters(self):
00047         from zope.app.testing import ztapi
00048         #from OFS.Image import File
00049 
00050         from Products.GenericSetup.interfaces import IFilesystemExporter
00051         from Products.GenericSetup.interfaces import IFilesystemImporter
00052         from Products.GenericSetup.interfaces import ICSVAware
00053         from Products.GenericSetup.interfaces import IINIAware
00054         from Products.CMFCore.interfaces import IFolderish
00055 
00056         from Products.CMFCore.exportimport.content import \
00057              StructureFolderWalkingAdapter
00058         from Products.GenericSetup.content import \
00059              CSVAwareFileAdapter
00060         from Products.GenericSetup.content import \
00061              INIAwareFileAdapter
00062 
00063         #from Products.CMFCore.exportimport.content import \
00064         #        OFSFileAdapter
00065 
00066         ztapi.provideAdapter(IFolderish,
00067                              IFilesystemExporter,
00068                              StructureFolderWalkingAdapter,
00069                             )
00070 
00071         ztapi.provideAdapter(IFolderish,
00072                              IFilesystemImporter,
00073                              StructureFolderWalkingAdapter,
00074                             )
00075 
00076         ztapi.provideAdapter(ICSVAware,
00077                              IFilesystemExporter,
00078                              CSVAwareFileAdapter,
00079                             )
00080 
00081         ztapi.provideAdapter(ICSVAware,
00082                              IFilesystemImporter,
00083                              CSVAwareFileAdapter,
00084                             )
00085 
00086         ztapi.provideAdapter(IINIAware,
00087                              IFilesystemExporter,
00088                              INIAwareFileAdapter,
00089                             )
00090 
00091         ztapi.provideAdapter(IINIAware,
00092                              IFilesystemImporter,
00093                              INIAwareFileAdapter,
00094                             )

Here is the caller graph for this function:

Definition at line 95 of file test_content.py.

00095 
00096     def tearDown(self):
00097         cleanUp()

Here is the call graph for this function:

Definition at line 98 of file test_content.py.

00098 
00099     def test_export_empty_site(self):
00100         self._setUpAdapters()
00101         site = _makeFolder('site', site_folder=True)
00102         site.title = 'test_export_empty_site'
00103         site.description = 'Testing export of an empty site.'
00104         context = DummyExportContext(site)
00105         exporter = self._getExporter()
00106         exporter(context)
00107 
00108         self.assertEqual(len(context._wrote), 2)
00109         filename, text, content_type = context._wrote[0]
00110         self.assertEqual(filename, 'structure/.objects')
00111         self.assertEqual(content_type, 'text/comma-separated-values')
00112 
00113         objects = [x for x in reader(StringIO(text))]
00114         self.assertEqual(len(objects), 0)
00115 
00116         filename, text, content_type = context._wrote[1]
00117         self.assertEqual(filename, 'structure/.properties')
00118         self.assertEqual(content_type, 'text/plain')
00119 
00120         parser = ConfigParser()
00121         parser.readfp(StringIO(text))
00122 
00123         self.assertEqual(parser.get('DEFAULT', 'Title'),
00124                          site.title)
00125         self.assertEqual(parser.get('DEFAULT', 'Description'),
00126                          site.description)

Here is the call graph for this function:

Definition at line 127 of file test_content.py.

00127 
00128     def test_export_empty_site_with_setup_tool(self):
00129         self._setUpAdapters()
00130         site = _makeFolder('site', site_folder=True)
00131         site._setObject('setup_tool', self._makeSetupTool())
00132         site.title = 'test_export_empty_site_with_setup_tool'
00133         site.description = 'Testing export of an empty site with setup tool.'
00134         context = DummyExportContext(site)
00135         exporter = self._getExporter()
00136         exporter(context)
00137 
00138         self.assertEqual(len(context._wrote), 2)
00139         filename, text, content_type = context._wrote[0]
00140         self.assertEqual(filename, 'structure/.objects')
00141         self.assertEqual(content_type, 'text/comma-separated-values')
00142 
00143         objects = [x for x in reader(StringIO(text))]
00144         self.assertEqual(len(objects), 0)
00145 
00146         filename, text, content_type = context._wrote[1]
00147         self.assertEqual(filename, 'structure/.properties')
00148         self.assertEqual(content_type, 'text/plain')
00149 
00150         parser = ConfigParser()
00151         parser.readfp(StringIO(text))
00152 
00153         self.assertEqual(parser.get('DEFAULT', 'Title'),
00154                          site.title)
00155         self.assertEqual(parser.get('DEFAULT', 'Description'),
00156                          site.description)

Here is the call graph for this function:

Definition at line 287 of file test_content.py.

00287 
00288     def test_export_site_with_csvaware(self):
00289         self._setUpAdapters()
00290 
00291         site = _makeFolder('site', site_folder=True)
00292         site.title = 'test_export_site_with_csvaware'
00293         site.description = 'Testing export of an site with CSV-aware content.'
00294 
00295         site._setObject('aware', _makeCSVAware('aware'))
00296 
00297         context = DummyExportContext(site)
00298         exporter = self._getExporter()
00299         exporter(context)
00300 
00301         self.assertEqual(len(context._wrote), 3)
00302         filename, text, content_type = context._wrote[0]
00303         self.assertEqual(filename, 'structure/.objects')
00304         self.assertEqual(content_type, 'text/comma-separated-values')
00305 
00306         objects = [x for x in reader(StringIO(text))]
00307         self.assertEqual(len(objects), 1)
00308         self.assertEqual(objects[0][0], 'aware')
00309         self.assertEqual(objects[0][1], TEST_CSV_AWARE)
00310 
00311         filename, text, content_type = context._wrote[1]
00312         self.assertEqual(filename, 'structure/.properties')
00313         self.assertEqual(content_type, 'text/plain')
00314 
00315         parser = ConfigParser()
00316         parser.readfp(StringIO(text))
00317 
00318         self.assertEqual(parser.get('DEFAULT', 'Title'),
00319                                     site.title)
00320         self.assertEqual(parser.get('DEFAULT', 'Description'),
00321                                     site.description)
00322 
00323         filename, text, content_type = context._wrote[2]
00324         self.assertEqual(filename, 'structure/aware.csv')
00325         self.assertEqual(content_type, 'text/comma-separated-values')
00326         rows = [x for x in reader(StringIO(text))]
00327         self.assertEqual(len(rows), 2)
00328         self.assertEqual(rows[0][0], 'one')
00329         self.assertEqual(rows[0][1], 'two')
00330         self.assertEqual(rows[0][2], 'three')
00331         self.assertEqual(rows[1][0], 'four')
00332         self.assertEqual(rows[1][1], 'five')
00333         self.assertEqual(rows[1][2], 'six')

Here is the call graph for this function:

Definition at line 191 of file test_content.py.

00191 
00192     def test_export_site_with_exportable_simple_items(self):
00193         self._setUpAdapters()
00194         ITEM_IDS = ('foo', 'bar', 'baz')
00195 
00196         site = _makeFolder('site', site_folder=True)
00197         site.title = 'AAA'
00198         site.description = 'BBB'
00199         for id in ITEM_IDS:
00200             site._setObject(id, _makeINIAware(id))
00201 
00202         context = DummyExportContext(site)
00203         exporter = self._getExporter()
00204         exporter(context)
00205 
00206         self.assertEqual(len(context._wrote), 2 + len(ITEM_IDS))
00207         filename, text, content_type = context._wrote[0]
00208         self.assertEqual(filename, 'structure/.objects')
00209         self.assertEqual(content_type, 'text/comma-separated-values')
00210 
00211         objects = [x for x in reader(StringIO(text))]
00212         self.assertEqual(len(objects), 3)
00213         for index in range(len(ITEM_IDS)):
00214             self.assertEqual(objects[index][0], ITEM_IDS[index])
00215             self.assertEqual(objects[index][1], TEST_INI_AWARE)
00216 
00217             filename, text, content_type = context._wrote[index+2]
00218             self.assertEqual(filename, 'structure/%s.ini' % ITEM_IDS[index])
00219             object = site._getOb(ITEM_IDS[index])
00220             self.assertEqual(text.strip(),
00221                              object.as_ini().strip())
00222             self.assertEqual(content_type, 'text/plain')
00223 
00224         filename, text, content_type = context._wrote[1]
00225         self.assertEqual(filename, 'structure/.properties')
00226         self.assertEqual(content_type, 'text/plain')
00227         parser = ConfigParser()
00228         parser.readfp(StringIO(text))
00229 
00230         self.assertEqual(parser.get('DEFAULT', 'title'), 'AAA')
00231         self.assertEqual(parser.get('DEFAULT', 'description'), 'BBB')

Here is the call graph for this function:

Definition at line 157 of file test_content.py.

00157 
00158     def test_export_site_with_non_exportable_simple_items(self):
00159         self._setUpAdapters()
00160         ITEM_IDS = ('foo', 'bar', 'baz')
00161 
00162         site = _makeFolder('site', site_folder=True)
00163         site.title = 'AAA'
00164         site.description = 'BBB'
00165         for id in ITEM_IDS:
00166             site._setObject(id, _makeItem(id))
00167 
00168         context = DummyExportContext(site)
00169         exporter = self._getExporter()
00170         exporter(context)
00171 
00172         self.assertEqual(len(context._wrote), 2)
00173         filename, text, content_type = context._wrote[0]
00174         self.assertEqual(filename, 'structure/.objects')
00175         self.assertEqual(content_type, 'text/comma-separated-values')
00176 
00177         objects = [x for x in reader(StringIO(text))]
00178         self.assertEqual(len(objects), 3)
00179         for index in range(len(ITEM_IDS)):
00180             self.assertEqual(objects[index][0], ITEM_IDS[index])
00181             self.assertEqual(objects[index][1], TEST_CONTENT)
00182 
00183         filename, text, content_type = context._wrote[1]
00184         self.assertEqual(filename, 'structure/.properties')
00185         self.assertEqual(content_type, 'text/plain')
00186         parser = ConfigParser()
00187         parser.readfp(StringIO(text))
00188 
00189         self.assertEqual(parser.get('DEFAULT', 'title'), 'AAA')
00190         self.assertEqual(parser.get('DEFAULT', 'description'), 'BBB')

Here is the call graph for this function:

Definition at line 232 of file test_content.py.

00232 
00233     def test_export_site_with_subfolders(self):
00234         self._setUpAdapters()
00235         FOLDER_IDS = ('foo', 'bar', 'baz')
00236 
00237         site = _makeFolder('site', site_folder=True)
00238         site.title = 'AAA'
00239         site.description = 'BBB'
00240         for id in FOLDER_IDS:
00241             folder = _makeFolder(id)
00242             folder.title = 'Title: %s' % id
00243             folder.description = 'xyzzy'
00244             site._setObject(id, folder)
00245 
00246         context = DummyExportContext(site)
00247         exporter = self._getExporter()
00248         exporter(context)
00249 
00250         self.assertEqual(len(context._wrote), 2 + (2 *len(FOLDER_IDS)))
00251         filename, text, content_type = context._wrote[0]
00252         self.assertEqual(filename, 'structure/.objects')
00253         self.assertEqual(content_type, 'text/comma-separated-values')
00254 
00255         objects = [x for x in reader(StringIO(text))]
00256         self.assertEqual(len(objects), 3)
00257 
00258         for index in range(len(FOLDER_IDS)):
00259             id = FOLDER_IDS[index]
00260             self.assertEqual(objects[index][0], id)
00261             self.assertEqual(objects[index][1], TEST_FOLDER)
00262 
00263             filename, text, content_type = context._wrote[2 + (2 * index)]
00264             self.assertEqual(filename, '/'.join(('structure', id, '.objects')))
00265             self.assertEqual(content_type, 'text/comma-separated-values')
00266             subobjects = [x for x in reader(StringIO(text))]
00267             self.assertEqual(len(subobjects), 0)
00268 
00269             filename, text, content_type = context._wrote[2 + (2 * index) + 1]
00270             self.assertEqual(filename,
00271                              '/'.join(('structure', id, '.properties')))
00272             self.assertEqual(content_type, 'text/plain')
00273             parser = ConfigParser()
00274             parser.readfp(StringIO(text))
00275 
00276             self.assertEqual(parser.get('DEFAULT', 'Title'), 'Title: %s' % id)
00277 
00278         filename, text, content_type = context._wrote[1]
00279         self.assertEqual(filename, 'structure/.properties')
00280         self.assertEqual(content_type, 'text/plain')
00281 
00282         parser = ConfigParser()
00283         parser.readfp(StringIO(text))
00284 
00285         self.assertEqual(parser.get('DEFAULT', 'title'), 'AAA')
00286         self.assertEqual(parser.get('DEFAULT', 'description'), 'BBB')

Here is the call graph for this function:

Definition at line 334 of file test_content.py.

00334 
00335     def test_import_empty_site(self):
00336         self._setUpAdapters()
00337         site = _makeFolder('site', site_folder=True)
00338         context = DummyImportContext(site)
00339         context._files['structure/.objects'] = ''
00340         importer = self._getImporter()
00341         self.assertEqual(len(site.objectIds()), 0)
00342         importer(context)
00343         self.assertEqual(len(site.objectIds()), 0)

Here is the call graph for this function:

Definition at line 344 of file test_content.py.

00344 
00345     def test_import_empty_site_with_setup_tool(self):
00346         self._setUpAdapters()
00347         site = _makeFolder('site', site_folder=True)
00348         site._setObject('setup_tool', self._makeSetupTool())
00349         context = DummyImportContext(site)
00350         importer = self._getImporter()
00351 
00352         self.assertEqual(len(site.objectIds()), 1)
00353         self.assertEqual(site.objectIds()[0], 'setup_tool')
00354         importer(context)
00355         self.assertEqual(len(site.objectIds()), 1)
00356         self.assertEqual(site.objectIds()[0], 'setup_tool')

Here is the call graph for this function:

Definition at line 357 of file test_content.py.

00357 
00358     def test_import_site_with_subfolders(self):
00359         from Products.GenericSetup.tests.test_content \
00360             import _PROPERTIES_TEMPLATE
00361         self._setUpAdapters()
00362         FOLDER_IDS = ('foo', 'bar', 'baz')
00363 
00364         site = _makeFolder('site', site_folder=True)
00365 
00366         context = DummyImportContext(site)
00367 
00368         for id in FOLDER_IDS:
00369             context._files['structure/%s/.objects' % id] = ''
00370             context._files['structure/%s/.properties' % id] = (
00371                 _PROPERTIES_TEMPLATE % id )
00372 
00373         _ROOT_OBJECTS = '\n'.join(['%s,%s' % (id, TEST_FOLDER)
00374                                         for id in FOLDER_IDS])
00375 
00376         context._files['structure/.objects'] = _ROOT_OBJECTS
00377         context._files['structure/.properties'] = (
00378                 _PROPERTIES_TEMPLATE % 'Test Site')
00379 
00380         importer = self._getImporter()
00381         importer(context)
00382 
00383         content = site.contentValues()
00384         self.assertEqual(len(content), len(FOLDER_IDS))

Here is the call graph for this function:

Definition at line 596 of file test_content.py.

00596 
00597     def test_import_site_with_subfolders_and_preserve(self):
00598         self._setUpAdapters()
00599 
00600         site = _makeFolder('site', site_folder=True)
00601         site._setObject('foo', _makeFolder('foo'))
00602         site.foo._setObject('bar', _makeFolder('bar'))
00603 
00604         context = DummyImportContext(site)
00605         # We want to add 'baz' to 'foo', without losing 'bar'
00606         context._files['structure/.objects'] = 'foo,%s' % TEST_FOLDER
00607         context._files['structure/.preserve'] = '*'
00608         context._files['structure/foo/.objects'] = 'baz,%s' % TEST_FOLDER
00609         context._files['structure/foo/.preserve'] = '*'
00610         context._files['structure/foo/baz/.objects'] = ''
00611 
00612         importer = self._getImporter()
00613         importer(context)
00614 
00615         self.assertEqual(len(site.objectIds()), 1)
00616         self.assertEqual(site.objectIds()[0], 'foo')
00617 
00618         self.assertEqual(len(site.foo.objectIds()), 2, site.foo.objectIds())
00619         self.assertEqual(site.foo.objectIds()[0], 'bar')
00620         self.assertEqual(site.foo.objectIds()[1], 'baz')
00621 

Here is the call graph for this function:

Definition at line 434 of file test_content.py.

00434 
00435     def test_import_site_with_subitem_unknown_portal_type(self):
00436         self._setUpAdapters()
00437         ITEM_IDS = ('foo', 'bar', 'baz')
00438 
00439         site = _makeFolder('site', site_folder=True)
00440 
00441         context = DummyImportContext(site)
00442         # We want to add 'baz' to 'foo', without losing 'bar'
00443         context._files['structure/.objects'] = '\n'.join(
00444                                 ['%s,Unknown Type' % x for x in ITEM_IDS])
00445         for index in range(len(ITEM_IDS)):
00446             id = ITEM_IDS[index]
00447             context._files[
00448                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00449                                                             'xyzzy',
00450                                                            )
00451 
00452         importer = self._getImporter()
00453         importer(context)
00454 
00455         after = site.objectIds()
00456         self.assertEqual(len(after), 0)
00457         self.assertEqual(len(context._notes), len(ITEM_IDS))
00458         for level, component, message in context._notes:
00459             self.assertEqual(component, 'SFWA')
00460             self.failUnless(message.startswith("Couldn't make"))

Here is the call graph for this function:

Definition at line 385 of file test_content.py.

00385 
00386     def test_import_site_with_subitems(self):
00387         self._setUpAdapters()
00388         ITEM_IDS = ('foo', 'bar', 'baz')
00389 
00390         site = _makeFolder('site', site_folder=True)
00391 
00392         context = DummyImportContext(site)
00393         # We want to add 'baz' to 'foo', without losing 'bar'
00394         context._files['structure/.objects'] = '\n'.join(
00395                             ['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
00396         for index in range(len(ITEM_IDS)):
00397             id = ITEM_IDS[index]
00398             context._files[
00399                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00400                                                             'xyzzy',
00401                                                            )
00402         importer = self._getImporter()
00403         importer(context)
00404 
00405         after = site.objectIds()
00406         self.assertEqual(len(after), len(ITEM_IDS))
00407         for found_id, expected_id in zip(after, ITEM_IDS):
00408             self.assertEqual(found_id, expected_id)

Here is the call graph for this function:

Definition at line 409 of file test_content.py.

00409 
00410     def test_import_site_with_subitems_and_blanklines_dotobjects(self):
00411         self._setUpAdapters()
00412         ITEM_IDS = ('foo', 'bar', 'baz')
00413 
00414         site = _makeFolder('site', site_folder=True)
00415 
00416         context = DummyImportContext(site)
00417         # We want to add 'baz' to 'foo', without losing 'bar'
00418         correct = '\n'.join(['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
00419         broken = correct + '\n\n'
00420         context._files['structure/.objects'] = broken
00421         for index in range(len(ITEM_IDS)):
00422             id = ITEM_IDS[index]
00423             context._files[
00424                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00425                                                             'xyzzy',
00426                                                            )
00427         importer = self._getImporter()
00428         importer(context)
00429 
00430         after = site.objectIds()
00431         self.assertEqual(len(after), len(ITEM_IDS))
00432         for found_id, expected_id in zip(after, ITEM_IDS):
00433             self.assertEqual(found_id, expected_id)

Here is the call graph for this function:

Definition at line 461 of file test_content.py.

00461 
00462     def test_reimport_no_structure_no_delete(self):
00463         self._setUpAdapters()
00464         ITEM_IDS = ('foo', 'bar', 'baz')
00465 
00466         site = _makeFolder('site', site_folder=True)
00467         for id in ITEM_IDS:
00468             site._setObject(id, _makeItem(id))
00469 
00470         context = DummyImportContext(site)
00471         # no defined structure => no deletion
00472         context._files['structure/.objects'] = ''
00473 
00474         importer = self._getImporter()
00475         importer(context)
00476 
00477         self.assertEqual(len(site.objectIds()), len(ITEM_IDS))

Here is the call graph for this function:

Definition at line 505 of file test_content.py.

00505 
00506     def test_reimport_with_structure_and_preserve(self):
00507         self._setUpAdapters()
00508         ITEM_IDS = ('foo', 'bar', 'baz')
00509 
00510         site = _makeFolder('site', site_folder=True)
00511         for id in ITEM_IDS:
00512             site._setObject(id, _makeINIAware(id))
00513             site._getOb(id).before = True
00514 
00515         context = DummyImportContext(site)
00516         context._files['structure/.objects'] = '\n'.join(
00517             ['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
00518         for index in range(len(ITEM_IDS)):
00519             id = ITEM_IDS[index]
00520             context._files[
00521                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00522                                                             'xyzzy',
00523                                                            )
00524         context._files['structure/.preserve'] = '*'
00525 
00526         importer = self._getImporter()
00527         importer(context)
00528 
00529         after = site.objectIds()
00530         self.assertEqual(len(after), len(ITEM_IDS))
00531         for i in range(len(ITEM_IDS)):
00532             self.assertEqual(after[i], ITEM_IDS[i])
00533             self.assertEqual(getattr(site._getOb(after[i]), 'before', None),
00534                              True)

Here is the call graph for this function:

Definition at line 535 of file test_content.py.

00535 
00536     def test_reimport_with_structure_and_preserve_partial(self):
00537         self._setUpAdapters()
00538         ITEM_IDS = ('foo', 'bar', 'baz')
00539 
00540         site = _makeFolder('site', site_folder=True)
00541         for id in ITEM_IDS:
00542             site._setObject(id, _makeINIAware(id))
00543             site._getOb(id).before = True
00544 
00545         context = DummyImportContext(site)
00546         context._files['structure/.objects'] = '\n'.join(
00547             ['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
00548         for index in range(len(ITEM_IDS)):
00549             id = ITEM_IDS[index]
00550             context._files[
00551                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00552                                                             'xyzzy',
00553                                                            )
00554         context._files['structure/.preserve'] = 'b*'
00555 
00556         importer = self._getImporter()
00557         importer(context)
00558 
00559         after = site.objectValues()
00560         self.assertEqual(len(after), len(ITEM_IDS))
00561         for obj in after:
00562             if obj.getId().startswith('b'):
00563                 self.assertEqual(getattr(obj, 'before', None), True)
00564             else:
00565                 self.assertEqual(getattr(obj, 'before', None), None)

Here is the call graph for this function:

Definition at line 478 of file test_content.py.

00478 
00479     def test_reimport_with_structure_does_delete(self):
00480         self._setUpAdapters()
00481         ITEM_IDS = ('foo', 'bar', 'baz')
00482 
00483         site = _makeFolder('site', site_folder=True)
00484         for id in ITEM_IDS:
00485             site._setObject(id, _makeItem(id))
00486             site._getOb(id).before = True
00487 
00488         context = DummyImportContext(site)
00489         # defined structure => object deleted and recreated
00490         context._files['structure/.objects'] = '\n'.join(
00491             ['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
00492         for index in range(len(ITEM_IDS)):
00493             id = ITEM_IDS[index]
00494             context._files[
00495                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00496                                                             'xyzzy',
00497                                                            )
00498 
00499         importer = self._getImporter()
00500         importer(context)
00501 
00502         self.assertEqual(len(site.objectIds()), len(ITEM_IDS))
00503         for obj in site.objectValues():
00504             self.failIf(hasattr(obj, 'before'))

Here is the call graph for this function:

Definition at line 566 of file test_content.py.

00566 
00567     def test_reimport_with_structure_partial_preserve_and_delete(self):
00568         self._setUpAdapters()
00569         ITEM_IDS = ('foo', 'bar', 'baz')
00570 
00571         site = _makeFolder('site', site_folder=True)
00572         for id in ITEM_IDS:
00573             site._setObject(id, _makeINIAware(id))
00574             site._getOb(id).before = True
00575 
00576         context = DummyImportContext(site)
00577         context._files['structure/.objects'] = '\n'.join(
00578             ['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS[:-1]])
00579         for index in range(len(ITEM_IDS)):
00580             id = ITEM_IDS[index]
00581             context._files[
00582                     'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
00583                                                             'xyzzy',
00584                                                            )
00585         context._files['structure/.preserve'] = 'foo'
00586         context._files['structure/.delete'] = 'baz'
00587 
00588         importer = self._getImporter()
00589         importer(context)
00590 
00591         after = site.objectIds()
00592         self.assertEqual(len(after), len(ITEM_IDS) - 1)
00593         self.failIf('baz' in after)
00594         self.assertEqual(getattr(site.foo, 'before', None), True)
00595         self.failIf(hasattr(site.bar, 'before'))

Here is the call graph for this function:


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