Test coverage for vnccollab.theme.testing
vnccollab/ | | covered 69% (1245 of 4098 uncovered) |
theme/ | | covered 69% (1245 of 4098 uncovered) |
testing.py | | covered 85% (12 of 80 uncovered) |
1: import sys
1: import transaction
1: from StringIO import StringIO
#import zope.component
#from zope.publisher.http import HTTPCharsets
1: from zope.interface import alsoProvides
1: from zope.publisher.browser import setDefaultSkin #, BrowserLanguages
1: from z3c.form.interfaces import IFormLayer
1: from ZPublisher.HTTPResponse import HTTPResponse
1: from ZPublisher.HTTPRequest import HTTPRequest
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: from plone.testing import z2
1: from zope.configuration import xmlconfig
1: try:
1: import vnccollab.cloudcast
>>>>>> except ImportError:
>>>>>> CAST_ENABLED = False
else:
1: CAST_ENABLED = True
2: class VNCThemeContent(PloneSandboxLayer):
1: defaultBases = (PLONE_FIXTURE,)
1: def setUpZope(self, app, configurationContext):
# zope.component.provideAdapter(HTTPCharsets)
# zope.component.provideAdapter(BrowserLanguages)
# Load ZCML
1: depedencies = ['collective.customizablePersonalizeForm',
1: 'collective.vaporisation', 'collective.quickupload',
1: 'plone.formwidget.autocomplete', 'Products.Carousel',
1: 'vnccollab.theme', 'collective.autopermission',
1: 'plone.app.iterate',
1: 'vnccollab.content',
1: 'Products.PloneLanguageTool'] #, 'plone.i18n', 'plone.app.i18n']
1: if CAST_ENABLED:
1: depedencies.extend([
#'collective.customizablePersonalizeForm',
1: 'plone.api', 'plone.app.discussion',
1: 'collective.prettydate', 'five.grok',
1: 'collective.autogroup','vnccollab.cloudcast',
1: 'vnccollab.cloudmobile'])
18: for package in depedencies:
17: module = __import__(package, fromlist=[''])
17: self.loadZCML(package=module)
1: if CAST_ENABLED:
1: z2.installProduct(app, 'vnccollab.cloudcast')
1: z2.installProduct(app, 'Products.PloneLanguageTool')
1: z2.installProduct(app, 'plone.app.locales')
# z2.installProduct(app, 'plone.app.layout')
# z2.installProduct(app, 'plone.app.i18n')
1: z2.installProduct(app, 'vnccollab.content')
1: z2.installProduct(app, 'vnccollab.theme')
1: z2.installProduct(app, 'Products.PythonScripts')
1: def setUpPloneSite(self, portal):
# Installs all the Plone stuff. Workflows etc.
1: self.applyProfile(portal, 'Products.CMFPlone:plone')
# Install portal content. Including the Members folder!
1: self.applyProfile(portal, 'Products.CMFPlone:plone-content')
#self.applyProfile(portal, 'Products.PloneLanguageTool:plone-default')
1: self.applyProfile(portal, 'vnccollab.content:default')
1: self.applyProfile(portal, 'vnccollab.theme:default')
1: if CAST_ENABLED:
1: self.applyProfile(portal, 'vnccollab.cloudcast:default')
1: VNCCOLLAB_THEME_FIXTURE = VNCThemeContent()
1: VNCCOLLAB_THEME_INTEGRATION_TESTING = IntegrationTesting(
1: bases=(VNCCOLLAB_THEME_FIXTURE,),
1: name='VNCThemeContent:Integration')
1: VNCCOLLAB_THEME_FUNCTIONAL_TESTING = FunctionalTesting(
1: bases=(VNCCOLLAB_THEME_FIXTURE,),
1: name='VNCThemeContent: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):
96: result = None
96: if delete_first and id in context.objectIds():
>>>>>> context.manage_delObjects([id])
96: if not check_for_first or id not in context.objectIds():
96: result = context[context.invokeFactory(_type, id, **kwargs)]
else:
>>>>>> result = context[id]
96: if object_date:
>>>>>> setObjDate(result, object_date)
96: transaction.commit()
96: return result