def test_archive_previous_versions_with_children_return(self): """ Test the return value for archival of the previous versions for the given object and their children """ version = create_version(self.folder) objects = archive_previous_versions(version, also_children=True) expected_output = [self.folder, self.doc] assert objects == expected_output
def test_archive_previous_versions(self): """ Test the archival of the previous versions for the given object """ version = create_version(self.folder) archive_previous_versions(version) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder)
def test_archive_previous_versions_with_children(self): """ Test the archival of the previous versions for the given object and their children """ version = create_version(self.folder) archive_previous_versions(version, also_children=True) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder) assert IObjectArchived.providedBy(self.doc)
def test_version_assigned_with_versions(self): """ Test assign on a version which will assign a new entered value on the given version. Notice that the older versions will keep the initial value """ current_id = IVersionControl(self.doc).versionId doc2 = create_version(self.doc) assert IVersionControl(self.doc).versionId == current_id assign_version(doc2, 'NEWVersion') assert IVersionControl(doc2).versionId != current_id
def test_archive_previous_versions_without_children(self): """ Test the archival of the previous versions for the given object even when calling the method that should archive also the children """ fid = self.portal.invokeFactory("Folder", 'f2') self.folder = self.portal[fid] version = create_version(self.folder) archive_previous_versions(version, also_children=True) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder)
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
def test_history_version(self): """ Test history version """ portal = self.portal fid = portal.invokeFactory("Folder", 'f1') folder = portal[fid] wftool = portal.portal_workflow wftool.doActionFor(folder, 'publish') version = create_version(folder) history = version.workflow_history['simple_publication_workflow'] assert len(history) == 3 assert history[0]['action'] == INITIAL_ITEM_CREATION assert history[1]['action'] == 'publish' assert history[2]['action'] == NEW_VERSION assert history[2]['review_state'] == history[0]['review_state']
def test_VersionModifier(self): """ Get publication date """ high = self.folder['h1'] # Highlights are not versionable by default, # so we need to make it versionable "by hand" alsoProvides(high, IVersionEnhanced) assign_new_version_id(high, None) ver = create_version(high) rdf = high.restrictedTraverse('@@rdf')() self.failUnless('<dcterms:isReplacedBy rdf:resource="' + 'http://nohost/plone/Members/test_user_1_/h1-1"/>' in rdf) rdf = ver.restrictedTraverse('@@rdf')() self.failUnless('<dcterms:replaces rdf:resource=' + '"http://nohost/plone/Members/test_user_1_/h1"/>' in rdf)
def addOrUpdateQuery(self, title, endpoint, query): """Update an already existing query Create new version""" oldSecurityManager = getSecurityManager() newSecurityManager(None, SpecialUsers.system) ob = None changed = True for sparql in self.values(): if sparql.title == title: x1 = IGetVersions(sparql) latest_sparql = x1.latest_version() ob = latest_sparql if latest_sparql.query_with_comments == query: changed = False break if not ob: _id = generateUniqueId("Sparql") _id = self.invokeFactory(type_name="Sparql", id=_id) ob = self[_id] ob.edit( title = title, endpoint_url = endpoint, sparql_query = query, ) ob._renameAfterCreation(check_auto_id=True) ob.invalidateWorkingResult() else: if changed: ob = versions.create_version(ob) ob.edit( sparql_query = query, ) ob.invalidateWorkingResult() setSecurityManager(oldSecurityManager) return ob
def addOrUpdateQuery(self, title, endpoint, query): """Update an already existing query Create new version""" oldSecurityManager = getSecurityManager() newSecurityManager(None, SpecialUsers.system) ob = None changed = True for sparql in self.values(): if sparql.title == title: x1 = IGetVersions(sparql) latest_sparql = x1.latest_version() ob = latest_sparql if latest_sparql.query_with_comments == query: changed = False break if not ob: _id = generateUniqueId("Sparql") _id = self.invokeFactory(type_name="Sparql", id=_id) ob = self[_id] ob.edit( title=title, endpoint_url=endpoint, sparql_query=query, ) ob._renameAfterCreation(check_auto_id=True) ob.invalidateWorkingResult() else: if changed: ob = versions.create_version(ob) ob.edit(sparql_query=query, ) ob.invalidateWorkingResult() setSecurityManager(oldSecurityManager) return ob
def test_version_random_id(self): """ Test the random version id of the object is 10 chars """ new_version = create_version(self.doc) assert len(IVersionControl(new_version).versionId) == 10
def test_version_obj(self): """ Test the versioning of the object """ new_version = create_version(self.doc) assert new_version != self.doc