Exemplo n.º 1
0
 def test_version_prefixed_first_id(self):
     """ Test the version id of a first object contains prefix-1 chars
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     assert IVersionControl(link).versionId == 'LNK-1'
Exemplo n.º 2
0
 def test_version_prefixed_revoked(self):
     """ Test the version id set to prefix-2 chars after version revoke
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     revoke_version(link)
     assert IVersionControl(link).versionId == 'LNK-2'
Exemplo n.º 3
0
 def test_version_prefixed_for_interface_portal_type(self):
     """ Test the version id of a first object contains prefix-1 chars
         if content type uses an interface not just a portal_type
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_interface = \
         'Products.ATContentTypes.interfaces.link.IATLink'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     assert IVersionControl(link).versionId == 'LNK-1'
Exemplo n.º 4
0
 def test_version_prefixed_first_version_id(self):
     """ Test the version id of a version contains the same version id
         as the object it derived from
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     link_version = create_version(link)
     assert IVersionControl(link_version).versionId == \
            IVersionControl(link).versionId
Exemplo n.º 5
0
 def create(self, data):
     """ Create
     """
     valid_input = input_is_valid(self, data)
     if not valid_input:
         return
     ob = PortalType(id=data.get('title', 'ADDTitle'))
     form.applyChanges(self, ob, data)
     return ob
Exemplo n.º 6
0
    def test_version_prefixed_translated_content(self):
        """ Test the version id of a translation contains the same version id
            as the object it derived from plus language id
        """
        if not has_lingua_plone:
            assert True
            return
        pvtool = getToolByName(self.portal, 'portal_eea_versions')
        vobjs = PortalType(id='LNK')
        vobjs.title = 'LNK'
        vobjs.search_type = 'Link'
        pvtool[vobjs.getId()] = vobjs
        link_id = self.folder.invokeFactory("Link", 'l1')
        link = self.folder[link_id]
        ITranslationFactory(self.folder)

        trans_lang = str(link.languages()[-1])
        translation = link.addTranslation(trans_lang)
        assert IVersionControl(translation).versionId == 'LNK-1-' + trans_lang
Exemplo n.º 7
0
 def test_version_prefixed_title_rename_with_translations_migration(self):
     """ Test the version id of all versions changes to match
         new prefix after performing migration and when having translations
     """
     if not has_lingua_plone:
         assert True
         return
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     assert IVersionControl(link).versionId == 'LNK-1'
     vobjs.title = 'LINK'
     link2_id = self.folder.invokeFactory("Link", 'l2')
     link2 = self.folder[link2_id]
     trans_lang = str(link.languages()[-1])
     trans_lang2 = str(link.languages()[-2])
     trans = link.addTranslation(trans_lang)
     trans2 = link.addTranslation(trans_lang2)
     # after tool object title is modified new version id will
     # use the new title
     assert IVersionControl(link2).versionId == 'LINK-2'
     # previous versions keep their prefix and number
     assert IVersionControl(link).versionId == 'LNK-1'
     migration_view = link.restrictedTraverse('@@migrateVersions')
     migration_view(prefix='LINK')
     # assert that now all of the links use the new LINK prefix
     # after running the migration script
     assert IVersionControl(link).versionId == 'LINK-1'
     assert IVersionControl(link2).versionId == 'LINK-2'
     assert IVersionControl(trans).versionId == 'LINK-1-' + trans_lang
     assert IVersionControl(trans2).versionId == 'LINK-1-' + trans_lang2
Exemplo n.º 8
0
 def test_version_prefixed_title_rename_with_migration(self):
     """ Test the version id of all versions changes to match
         new prefix after performing migration
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     assert IVersionControl(link).versionId == 'LNK-1'
     vobjs.title = 'LINK'
     link2_id = self.folder.invokeFactory("Link", 'l2')
     link2 = self.folder[link2_id]
     # after tool object title is modified new version id will
     # use the new title
     assert IVersionControl(link2).versionId == 'LINK-2'
     # previous versions keep their prefix and number
     assert IVersionControl(link).versionId == 'LNK-1'
     migration_view = link.restrictedTraverse('@@migrateVersions')
     migration_view(prefix='LINK')
     # assert that now all of the links use the new LINK prefix
     # after running the migration script
     assert IVersionControl(link).versionId == 'LINK-1'
     assert IVersionControl(link2).versionId == 'LINK-2'
Exemplo n.º 9
0
 def test_version_prefixed_with_language(self):
     """ Test the version id of a version contains prefix plus language id
         if prefix_with_language is set on version object
     """
     if not has_lingua_plone:
         assert True
         return
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     vobjs.prefix_with_language = True
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     link_lang = link.getLanguage()
     assert IVersionControl(link).versionId == 'LNK-1-' + link_lang
Exemplo n.º 10
0
 def test_version_prefixed_title_rename(self):
     """ Test the version id of a new object changes to match
         new prefix
     """
     pvtool = getToolByName(self.portal, 'portal_eea_versions')
     vobjs = PortalType(id='LNK')
     vobjs.title = 'LNK'
     vobjs.search_type = 'Link'
     pvtool[vobjs.getId()] = vobjs
     link_id = self.folder.invokeFactory("Link", 'l1')
     link = self.folder[link_id]
     assert IVersionControl(link).versionId == 'LNK-1'
     vobjs.title = 'LINK'
     link2_id = self.folder.invokeFactory("Link", 'l2')
     link2 = self.folder[link2_id]
     # after tool object title is modified new version id will
     # use the new title
     assert IVersionControl(link2).versionId == 'LINK-2'
     # previous versions keep their prefix and number
     assert IVersionControl(link).versionId == 'LNK-1'