def test_switch_to_dexterity_builders(self):
        with at_content_builders_registered():
            self.assert_builders_are_instances_of(ArchetypesBuilder)

            with dx_content_builders_registered():
                self.assert_builders_are_instances_of(DexterityBuilder)

            self.assert_builders_are_instances_of(ArchetypesBuilder)
Exemple #2
0
    def test_migrate_dexterity_folder_to_dexterity(self):
        self.grant('Manager')
        self.install_profile('plone.app.contenttypes:default')

        creation_date = datetime(2015, 11, 29, 10, 45)
        modification_date = datetime(2016, 1, 2, 9, 30)
        effective_date = datetime(2016, 2, 2, 2, 30)
        expires_date = datetime(2016, 3, 3, 3, 30)

        with dx_content_builders_registered():
            with freeze(creation_date):
                folder = create(Builder('folder')
                                .titled(u'The Folder')
                                .having(description=u'The Description',
                                        exclude_from_nav=True,
                                        subjects=(u'One', u'Two'),
                                        effective=effective_date,
                                        expires=expires_date)
                                .in_state('pending'))

        with freeze(modification_date):
            folder.reindexObject()  # update modification date

        self.assertFalse(IBaseObject.providedBy(folder))
        self.assertTrue(IDexterityContent.providedBy(folder))
        self.assertEqual(('', 'plone', 'the-folder'), folder.getPhysicalPath())
        self.assertEqual('The Folder', folder.Title())
        self.assertEqual('The Description', folder.Description())
        self.assertEqual(True, folder.exclude_from_nav)
        self.assertEqual(('One', 'Two'), folder.Subject())
        self.assertEqual(todt(creation_date), todt(folder.created()))
        self.assertEqual(todt(modification_date), todt(folder.modified()))
        self.assertEqual(todt(effective_date), todt(folder.effective()))
        self.assertEqual(todt(expires_date), todt(folder.expires()))
        self.assertEqual('pending', self.review_state(folder))

        old_catalog_indexdata = self.get_catalog_indexdata_for(folder)

        InplaceMigrator('Folder').migrate_object(folder)

        folder = self.portal.get('the-folder')
        self.assertFalse(IBaseObject.providedBy(folder))
        self.assertTrue(IDexterityContent.providedBy(folder))
        self.assertEqual(('', 'plone', 'the-folder'), folder.getPhysicalPath())
        self.assertEqual('The Folder', folder.Title())
        self.assertEqual('The Description', folder.Description())
        self.assertEqual(True, folder.exclude_from_nav)
        self.assertEqual(('One', 'Two'), folder.Subject())
        self.assertEqual(todt(creation_date), todt(folder.created()))
        self.assertEqual(todt(modification_date), todt(folder.modified()))
        self.assertEqual(todt(effective_date), todt(folder.effective()))
        self.assertEqual(todt(expires_date), todt(folder.expires()))
        self.assertEqual('pending', self.review_state(folder))

        self.maxDiff = None
        self.assertDictEqual(old_catalog_indexdata,
                             self.get_catalog_indexdata_for(folder))
Exemple #3
0
    def test_migrate_dexterity_folder_to_dexterity(self):
        self.grant('Manager')
        self.install_profile('plone.app.contenttypes:default')

        creation_date = datetime(2015, 11, 29, 10, 45)
        modification_date = datetime(2016, 1, 2, 9, 30)
        effective_date = datetime(2016, 2, 2, 2, 30)
        expires_date = datetime(2016, 3, 3, 3, 30)

        with dx_content_builders_registered():
            with freeze(creation_date):
                folder = create(
                    Builder('folder').titled(u'The Folder').having(
                        description=u'The Description',
                        exclude_from_nav=True,
                        subjects=(u'One', u'Two'),
                        effective=effective_date,
                        expires=expires_date).in_state('pending'))

        with freeze(modification_date):
            folder.reindexObject()  # update modification date

        self.assertFalse(IBaseObject.providedBy(folder))
        self.assertTrue(IDexterityContent.providedBy(folder))
        self.assertEqual(('', 'plone', 'the-folder'), folder.getPhysicalPath())
        self.assertEqual('The Folder', folder.Title())
        self.assertEqual('The Description', folder.Description())
        self.assertEqual(True, folder.exclude_from_nav)
        self.assertEqual(('One', 'Two'), folder.Subject())
        self.assertEqual(todt(creation_date), todt(folder.created()))
        self.assertEqual(todt(modification_date), todt(folder.modified()))
        self.assertEqual(todt(effective_date), todt(folder.effective()))
        self.assertEqual(todt(expires_date), todt(folder.expires()))
        self.assertEqual('pending', self.review_state(folder))

        old_catalog_indexdata = self.get_catalog_indexdata_for(folder)

        InplaceMigrator('Folder').migrate_object(folder)

        folder = self.portal.get('the-folder')
        self.assertFalse(IBaseObject.providedBy(folder))
        self.assertTrue(IDexterityContent.providedBy(folder))
        self.assertEqual(('', 'plone', 'the-folder'), folder.getPhysicalPath())
        self.assertEqual('The Folder', folder.Title())
        self.assertEqual('The Description', folder.Description())
        self.assertEqual(True, folder.exclude_from_nav)
        self.assertEqual(('One', 'Two'), folder.Subject())
        self.assertEqual(todt(creation_date), todt(folder.created()))
        self.assertEqual(todt(modification_date), todt(folder.modified()))
        self.assertEqual(todt(effective_date), todt(folder.effective()))
        self.assertEqual(todt(expires_date), todt(folder.expires()))
        self.assertEqual('pending', self.review_state(folder))

        self.maxDiff = None
        self.assertDictEqual(old_catalog_indexdata,
                             self.get_catalog_indexdata_for(folder))