def test_after_checkin(self): baseline = createContentInContainer(self.folder, 'stageable_type') working_copy = self.do_checkout(baseline) new_baseline = self.do_checkin(working_copy) relation = IWCAnnotator(new_baseline).get_relation() self.assertIsNone(relation) self.assertIsNone(get_checkout_relation(new_baseline))
def test_after_cancel_checkout(self): """When user cancel checkout relation to baseline is None""" baseline = createContentInContainer(self.folder, 'stageable_type') working_copy = self.do_checkout(baseline) self.do_cancel(working_copy) relation = IWCAnnotator(baseline).get_relation() self.assertIsNone(relation) self.assertIsNone(get_checkout_relation(baseline))
def test_after_checkout(self): baseline = createContentInContainer(self.folder, 'stageable_type') working_copy = self.do_checkout(baseline) relation = IWCAnnotator(baseline).get_relation() self.assertEqual(relation.to_object, working_copy) self.assertEqual(relation.from_object, baseline) self.assertEqual(get_checkout_relation(baseline), relation)
def test_edit_baseline(self): """Some time somebody can edit a IBaseline object and updateRelations subscriber in z3c.relationfield package, will delete all reference before to update them. """ baseline = createContentInContainer(self.folder, 'stageable_type') working_copy = self.do_checkout(baseline) baseline.title = u'new title' # XXX: aq_base is necessary to prevent error: # "TypeError: Can't pickle objects in acquisition wrappers." # in CMFEdition notify(ObjectModifiedEvent(aq_base(baseline))) relation = get_checkout_relation(baseline) annotation = IWCAnnotator(baseline).get_relation() self.assertIsNotNone(relation) self.assertEqual(relation, annotation)
def checkout_allowed(self): """ Check if a checkout is allowed. Conditions: - provides IIterateAware - is versionable - there is no checkout """ context = aq_inner( self.context ) if not interfaces.IIterateAware.providedBy( context ): return False archiver = interfaces.IObjectArchiver(context) if not archiver.isVersionable(): return False if get_checkout_relation( context ): return False return True
def properties(self): relation = get_checkout_relation(self.context) if relation: return relation.staging_properties else: return None
def _getReference(self): return get_checkout_relation(self.context)