Test coverage for vnccollab.content.testing
1: import transaction
1: from plone.testing import z2
1: from plone.app.testing import PloneSandboxLayer
1: from plone.app.testing import applyProfile
1: from plone.app.testing import PLONE_FIXTURE
1: from plone.app.testing import IntegrationTesting
1: from plone.app.testing import FunctionalTesting
1: import collective.customizablePersonalizeForm
2: class VnccollabContentLayer(PloneSandboxLayer):
1: defaultBases = (PLONE_FIXTURE,)
1: def setUpZope(self, app, configurationContext):
# Load ZCML
dependencies = [
1: 'raptus.autocompletewidget',
1: 'collective.customizablePersonalizeForm',
1: 'vnccollab.content',
]
4: for package in dependencies:
3: module = __import__(package, fromlist=[''])
3: self.loadZCML(package=module)
1: self.loadZCML(package=collective.customizablePersonalizeForm,
1: name='overrides.zcml')
1: z2.installProduct(app, 'collective.customizablePersonalizeForm')
1: z2.installProduct(app, 'vnccollab.content')
1: def setUpPloneSite(self, portal):
1: applyProfile(portal, 'collective.customizablePersonalizeForm:default')
1: applyProfile(portal, 'vnccollab.content:default')
1: VNCCOLLAB_CONTENT_FIXTURE = VnccollabContentLayer()
1: VNCCOLLAB_CONTENT_INTEGRATION_TESTING = IntegrationTesting(
1: bases=(VNCCOLLAB_CONTENT_FIXTURE,),
1: name='VnccollabContentLayer:Integration')
1: VNCCOLLAB_CONTENT_FUNCTIONAL_TESTING = FunctionalTesting(
1: bases=(VNCCOLLAB_CONTENT_FIXTURE,),
1: name='VnccollabContentLayer:Functional')
1: def setObjDate(obj, dt):
"""Prevent update of modification date
during reindexing"""
>>>>>> obj.setCreationDate(dt)
>>>>>> obj.setEffectiveDate(dt)
>>>>>> obj.setModificationDate(dt)
>>>>>> od = obj.__dict__
>>>>>> od['notifyModified'] = lambda *args: None
>>>>>> obj.reindexObject()
>>>>>> del od['notifyModified']
1: def createObject(context, _type, id, delete_first=True, check_for_first=False,
1: object_date=None, **kwargs):
7: result = None
7: if delete_first and id in context.objectIds():
>>>>>> context.manage_delObjects([id])
7: if not check_for_first or id not in context.objectIds():
7: result = context[context.invokeFactory(_type, id, **kwargs)]
else:
>>>>>> result = context[id]
7: if object_date:
>>>>>> setObjDate(result, object_date)
7: transaction.commit()
7: return result