def setUp(self): super(SiteManagerTest, self).setUp() self.root = root = Root() self.f1 = f1 = Folder().__of__(root) self.sm1 = sm1 = ServiceManager() f1.setSiteManager(sm1) self.p1 = p1 = Package().__of__(sm1) self.f2 = f2 = Folder().__of__(f1) self.sm2 = sm2 = ServiceManager() f2.setSiteManager(sm2) self.p2 = p2 = Package().__of__(sm2) sm1.next = serviceManager sm2.next = sm1 self.unparented_folder = Folder() self.unrooted_subfolder = Folder().__of__(self.unparented_folder) zcml.load_config("meta.zcml", Products.Five) zcml.load_config("permissions.zcml", Products.Five) zcml.load_config("configure.zcml", Products.Five.site) zcml_text = """\ <five:localsite xmlns:five="http://namespaces.zope.org/five" class="Products.Five.site.tests.dummy.DummySite" />""" zcml.load_string(zcml_text)
def setUp(self): PlacelessSetup.setUp(self) RequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) zcml.load_string(_TRAVERSE_ZCML) try: factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite factory('cmf', 'CMFDefault:default', snapshot=False) self.portal = self.root.cmf # Become a Manager self.uf = self.portal.acl_users self.uf.userFolderAddUser('manager', '', ['Manager'], []) self.login('manager') # Make a document self.discussion = self.portal.portal_discussion self.portal.invokeFactory('Document', id='doc') self.discussion.overrideDiscussionFor(self.portal.doc, 1) # Publish it self.workflow = self.portal.portal_workflow self.workflow.doActionFor(self.portal.doc, 'publish') except: self.tearDown() raise
def afterSetUp(self): setUp() root = Wrapper(self.folder, Root()) f1 = Wrapper(Folder(), root) sm1 = ServiceManager() f1.setSiteManager(sm1) p1 = Wrapper(Package(), sm1) f2 = Wrapper(Folder(), f1) sm2 = ServiceManager() f2.setSiteManager(sm2) p2 = Wrapper(Package(), sm2) sm1.next = serviceManager sm2.next = sm1 self.root = root self.f1 = f1 self.f2 = f2 self.sm1 = sm1 self.sm2 = sm2 self.p1 = p1 self.p2 = p2 self.unparented_folder = Folder() self.unrooted_subfolder = Wrapper(Folder(), self.unparented_folder) zcml.load_config("meta.zcml", Products.Five) zcml.load_config("localsite.zcml", Products.Five) zcml_text = """<configure xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five"> <five:localsite class="Products.Five.testing.localsite.DummySite" /> </configure>""" zcml.load_string(zcml_text)
def setUp(self): super(SiteManagerTest, self).setUp() self.root = root = Root() self.f1 = f1 = Folder().__of__(root) self.sm1 = sm1 = SiteManager() f1.setSiteManager(sm1) self.p1 = p1 = Package().__of__(sm1) self.f2 = f2 = Folder().__of__(f1) self.sm2 = sm2 = SiteManager() f2.setSiteManager(sm2) self.p2 = p2 = Package().__of__(sm2) sm1.next = getGlobalSiteManager() sm2.next = sm1 self.unparented_folder = Folder() self.unrooted_subfolder = Folder().__of__(self.unparented_folder) zcml.load_config("meta.zcml", Products.Five) zcml.load_config("permissions.zcml", Products.Five) zcml.load_config("configure.zcml", Products.Five.site) zcml_text = """\ <five:localsite xmlns:five="http://namespaces.zope.org/five" class="Products.Five.site.tests.dummy.DummySite" />""" zcml.load_string(zcml_text) # Hook up custom component architecture calls; we need to do # this here because zope.app.component.hooks registers a # cleanup with the testing cleanup framework, so the hooks get # torn down by placelesssetup each time. setHooks()
def test_bad_view_definition(self): """ Try render non-existing browser:page """ bad_button_configure_zcml = ''' <configure xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five" xmlns:paymentprocessors="http://namespaces.plonegetpaid.com/paymentprocessors" xmlns:browser="http://namespaces.zope.org/browser" i18n_domain="foo"> <paymentprocessors:registerProcessor name="dummy" processor="getpaid.paymentprocessors.tests.dummies.DummyProcessor" selection_view="BAD_ENTRY_HERE" thank_you_view="dummy_payment_processor_thank_you_page" /> </configure>''' zcml.load_string(bad_button_configure_zcml) view = self.portal.restrictedTraverse("@@getpaid-checkout-wizard") try: view() raise AssertionError("Should not be never reached") except BadViewConfigurationException: pass
def afterSetUp(self): # needed if this is run directly on the commandline, # since otherwise it will be __main__, and ZPL's afterSetup # will get confused. self.__module__ = 'ZenPacks.zenoss.OpenStackInfrastructure.tests.test_impact' super(TestImpact, self).afterSetUp() import Products.ZenEvents zcml.load_config('meta.zcml', Products.ZenEvents) # For Zenoss 4.1.1 zcml.load_string(''' <configure> <include package="zope.viewlet" file="meta.zcml" /> </configure>''') try: import ZenPacks.zenoss.DynamicView zcml.load_config('configure.zcml', ZenPacks.zenoss.DynamicView) except ImportError: return try: import ZenPacks.zenoss.Impact zcml.load_config('meta.zcml', ZenPacks.zenoss.Impact) zcml.load_config('configure.zcml', ZenPacks.zenoss.Impact) except ImportError: return import ZenPacks.zenoss.OpenStackInfrastructure zcml.load_config('configure.zcml', ZenPacks.zenoss.OpenStackInfrastructure)
def setUp(self): PlacelessSetup.setUp(self) RequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) zcml.load_string(_TRAVERSE_ZCML) try: newSecurityManager( None, UnrestrictedUser('manager', '', ['Manager'], [])) factory = self.root.manage_addProduct[ 'CMFDefault'].addConfiguredSite factory('cmf', 'CMFDefault:default', snapshot=False) self.site = self.root.cmf self.site.invokeFactory('File', id='file') self.site.portal_workflow.doActionFor(self.site.file, 'publish') self.site.invokeFactory('Image', id='image') self.site.portal_workflow.doActionFor(self.site.image, 'publish') self.site.invokeFactory('Folder', id='subfolder') self.subfolder = self.site.subfolder self.workflow = self.site.portal_workflow transaction.savepoint(optimistic=True) # Make sure we have _p_jars except: self.tearDown() raise
def afterSetUp(self): setUp() zcml.load_config("meta.zcml", Products.Five) zcml.load_config("permissions.zcml", Products.Five) zcml.load_config("configure.zcml", Products.Five.component) zcml.load_config("configure.zcml", Products.Five.site) zcml_text = """\ <five:localsite xmlns:five="http://namespaces.zope.org/five" class="Products.Five.site.tests.dummy.DummySite" />""" import warnings showwarning = warnings.showwarning warnings.showwarning = lambda *a, **k: None zcml.load_string(zcml_text) manage_addDummySite(self.folder, 'site') enableLocalSiteHook(self.folder.site) warnings.showwarning = showwarning # Hook up custom component architecture calls; we need to do # this here because zope.app.component.hooks registers a # cleanup with the testing cleanup framework, so the hooks get # torn down by placelesssetup each time. setHooks()
def setUp(self): RequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) zcml.load_string(_TRAVERSE_ZCML) try: factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite factory('cmf', 'CMFDefault:default', snapshot=False) self.portal = self.root.cmf # Become a Manager self.uf = self.portal.acl_users self.uf.userFolderAddUser('manager', '', ['Manager'], []) self.login('manager') # Make a document self.discussion = self.portal.portal_discussion self.portal.invokeFactory('Document', id='doc') self.discussion.overrideDiscussionFor(self.portal.doc, 1) # Publish it self.workflow = self.portal.portal_workflow self.workflow.doActionFor(self.portal.doc, 'publish') except: self.tearDown() raise
def test_page_security(self): decl = """ <configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <browser:page for="Products.Five.tests.dummy.IDummy" class="Products.Five.tests.dummy.DummyView" attribute="foo" name="test_page_security" permission="zope2.ViewManagementScreens" /> </configure> """ zcml.load_string(decl) request = FakeRequest() # Wrap into an acquisition so that imPermissionRole objects # can be evaluated. view = getView(Dummy1(), 'test_page_security', request) ac = getattr(view, '__ac_permissions__') # It's protecting the object with the permission, and not the # attribute, so we get ('',) instead of ('foo',). ex_ac = (('View management screens', ('',)),) self.assertEquals(ac, ex_ac) # Wrap into an acquisition so that imPermissionRole objects # can be evaluated. __roles__ is a imPermissionRole object. view = view.__of__(self.folder) view_roles = getattr(view, '__roles__', None) self.failIf(view_roles is None) self.failIf(view_roles == ()) self.assertEquals(view_roles, ('Manager',))
def setUp(self): PlacelessSetup.setUp(self) RequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) zcml.load_string(_TRAVERSE_ZCML) try: newSecurityManager(None, UnrestrictedUser('manager', '', ['Manager'], [])) factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite factory('cmf', 'CMFDefault:default', snapshot=False) self.site = self.root.cmf self.site.invokeFactory('File', id='file') self.site.portal_workflow.doActionFor(self.site.file, 'publish') self.site.invokeFactory('Image', id='image') self.site.portal_workflow.doActionFor(self.site.image, 'publish') self.site.invokeFactory('Folder', id='subfolder') self.subfolder = self.site.subfolder self.workflow = self.site.portal_workflow transaction.savepoint(optimistic=True) # Make sure we have _p_jars except: self.tearDown() raise
def test_bad_processor(self): """ Check that ZCML entry which has bad processor declaration is caught """ try: zcml.load_string(bad_processor_zcml) raise AssertionError("Should not be never reached") except ConfigurationError, e: pass
def setUp(self): SecurityRequestTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.DCWorkflow) zcml.load_string(_TRAVERSE_ZCML)
def afterSetUp(self): setUp() zcml.load_config("meta.zcml", Products.Five) zcml.load_config("localsite.zcml", Products.Five) zcml_text = """<configure xmlns:five="http://namespaces.zope.org/five"> <five:localsite class="Products.Five.testing.localsite.DummySite" /> </configure>""" zcml.load_string(zcml_text)
def testOneStepImport(self): zcml.load_string(ONE_STEP_ZCML) self.assertEqual(_import_step_registry._registered.keys(), [u'Products.GenericSetup.teststep']) info = _import_step_registry._registered[ u'Products.GenericSetup.teststep'] self.assertEqual(info['description'], u'step description') self.assertEqual(info['title'], u'step title') self.assertEqual(info['handler'], 'Products.GenericSetup.initialize') self.assertEqual(info['id'], u'Products.GenericSetup.teststep')
def setUpTraversing(): import Products.Five zcml.load_config('meta.zcml', Products.Five) try: import zope.traversing zcml.load_config('traversing.zcml', Products.Five) except ImportError: # BBB: for Zope 2.9 zcml.load_string(_TRAVERSE_ZCML)
def setUp(self): import Products.CMFCore.exportimport from Products.CMFCore.WorkflowTool import WorkflowTool BodyAdapterTestCase.setUp(self) zcml.load_config('configure.zcml', Products.CMFCore.exportimport) zcml.load_string(_DUMMY_ZCML) self._obj = WorkflowTool() self._BODY = _WORKFLOWTOOL_BODY
def register_browser_resources(self): """Register browser resources if they exist.""" zenpack_path = get_zenpack_path(self.name) if not zenpack_path: return resource_path = os.path.join(zenpack_path, 'resources') if not os.path.isdir(resource_path): return directives = [] directives.append( '<resourceDirectory name="{name}" directory="{directory}"/>'. format(name=self.name, directory=resource_path)) def get_directive(name, for_, weight): path = os.path.join(resource_path, '{}.js'.format(name)) if not os.path.isfile(path): return return ( '<viewlet' ' name="js-{zenpack_name}-{name}"' ' paths="/++resource++{zenpack_name}/{name}.js"' ' for="{for_}"' ' weight="{weight}"' ' manager="Products.ZenUI3.browser.interfaces.IJavaScriptSrcManager"' ' class="Products.ZenUI3.browser.javascript.JavaScriptSrcBundleViewlet"' ' permission="zope.Public"' ' />'.format(name=name, for_=for_, weight=weight, zenpack_name=self.name)) directives.append(get_directive('global', '*', 20)) for spec in self.ordered_classes: if spec.is_device: for_ = get_symbol_name(self.name, spec.name, spec.name) directives.append(get_directive('device', for_, 21)) directives.append(get_directive(spec.name, for_, 22)) # Eliminate None items from list of directives. directives = tuple(x for x in directives if x) if directives: zcml.load_string( '<configure xmlns="http://namespaces.zope.org/browser">' '<include package="Products.Five" file="meta.zcml"/>' '<include package="Products.Five.viewlet" file="meta.zcml"/>' '{directives}' '</configure>'.format(name=self.name, directory=resource_path, directives=''.join(directives)))
def test_equivalence(self): self.failIf(hasattr(self.dummy1, '__ac_permissions__')) self.failIf(hasattr(self.dummy2, '__ac_permissions__')) decl = """ <configure xmlns="http://namespaces.zope.org/zope"> <content class="Products.Five.tests.dummy.Dummy1"> <allow attributes="foo" /> <!-- XXX not yet supported <deny attributes="baz" /> --> <require attributes="bar keg" permission="zope2.ViewManagementScreens" /> </content> </configure> """ zcml.load_string(decl) InitializeClass(self.dummy2) ac1 = getattr(self.dummy1, '__ac_permissions__') ac2 = getattr(self.dummy2, '__ac_permissions__') self.assertEquals(ac1, ac2) bar_roles1 = getattr(self.dummy1, 'bar__roles__').__of__(self.dummy1) self.assertEquals(bar_roles1.__of__(self.dummy1), ('Manager',)) keg_roles1 = getattr(self.dummy1, 'keg__roles__').__of__(self.dummy1) self.assertEquals(keg_roles1.__of__(self.dummy1), ('Manager',)) foo_roles1 = getattr(self.dummy1, 'foo__roles__') self.assertEquals(foo_roles1, None) # XXX Not yet supported. # baz_roles1 = getattr(self.dummy1, 'baz__roles__') # self.assertEquals(baz_roles1, ()) bar_roles2 = getattr(self.dummy2, 'bar__roles__').__of__(self.dummy2) self.assertEquals(bar_roles2.__of__(self.dummy2), ('Manager',)) keg_roles2 = getattr(self.dummy2, 'keg__roles__').__of__(self.dummy2) self.assertEquals(keg_roles2.__of__(self.dummy2), ('Manager',)) foo_roles2 = getattr(self.dummy2, 'foo__roles__') self.assertEquals(foo_roles2, None) baz_roles2 = getattr(self.dummy2, 'baz__roles__') self.assertEquals(baz_roles2, ())
def setUp(cls): import Products.Five import Products.GenericSetup import Products.CMFCore import Products.CMFCore.exportimport zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('tool.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.CMFCore.exportimport) zcml.load_string(_DUMMY_ZCML)
def testSavedVersionHistory(self): # check current version of report (should be empty) self.checkForExistingCallHomeData() # set up test version history collector zcml.load_string(TEST_VERSION_HISTORY_COLLECTOR) # generate callhome chd = CallHomeData(self.dmd, True) data = chd.getData() firstReportDate = data[REPORT_DATE_KEY] time.sleep(1) # make sure version history record is present and correct self.assertTrue(VERSION_HISTORIES_KEY in data) versionHistories = data[VERSION_HISTORIES_KEY] self.assertTrue(TEST_VERSION_HISTORY_ENTITY in versionHistories) versionHistory = versionHistories[TEST_VERSION_HISTORY_ENTITY] self.assertTrue(TEST_VERSION_1 in versionHistory) historyRecord = versionHistory[TEST_VERSION_1] self.assertTrue(VERSION_START_KEY in historyRecord) self.assertEquals(firstReportDate, historyRecord[VERSION_START_KEY]) # The cycler code is where the saving of # callhome data in ZODB occurs. We'll have # to mimic that again here. self.dmd.callHome = PersistentCallHomeData() self.dmd.callHome.metrics = json.dumps(data) # update the version history global TEST_CURRENT_VERSION TEST_CURRENT_VERSION = TEST_VERSION_2 # generate callhome again chd = CallHomeData(self.dmd, True) data = chd.getData() secondReportDate = data[REPORT_DATE_KEY] # make sure a second version history record exists self.assertTrue(VERSION_HISTORIES_KEY in data) versionHistories = data[VERSION_HISTORIES_KEY] self.assertTrue(TEST_VERSION_HISTORY_ENTITY in versionHistories) versionHistory = versionHistories[TEST_VERSION_HISTORY_ENTITY] self.assertTrue(TEST_VERSION_1 in versionHistory) historyRecord = versionHistory[TEST_VERSION_1] self.assertTrue(VERSION_START_KEY in historyRecord) self.assertEquals(firstReportDate, historyRecord[VERSION_START_KEY]) self.assertTrue(TEST_VERSION_2 in versionHistory) historyRecord = versionHistory[TEST_VERSION_2] self.assertTrue(VERSION_START_KEY in historyRecord) self.assertEquals(secondReportDate, historyRecord[VERSION_START_KEY])
def afterSetUp(self): """This method is called before each single test. It can be used to set up common state. Setup that is specific to a particular test should be done in that test method. """ zcml.load_string(configure_zcml) self.setRoles(['Manager', 'Member']) self.portal.invokeFactory('Folder','folder') self.folder = self.portal['folder'] self.folder.invokeFactory('Document','document') self.obj = self.folder['document'] interface.alsoProvides(self.obj,IReadByProvider) setupMembers(self.portal)
def afterSetUp(self): setUp() zcml.load_config("meta.zcml", Products.Five) zcml.load_config("localsite.zcml", Products.Five) zcml_text = """<configure xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five"> <five:localsite class="Products.CMFCore.PortalObject.PortalObjectBase" /> </configure>""" zcml.load_string(zcml_text) portal = PortalObjectBase('portal') self.app._setObject('portal', portal)
def afterSetUp(self): setUp() zcml.load_config("meta.zcml", Products.Five) zcml.load_config("permissions.zcml", Products.Five) zcml.load_config("configure.zcml", Products.Five.site) zcml_text = """\ <five:localsite xmlns:five="http://namespaces.zope.org/five" class="Products.Five.site.tests.dummy.DummySite" />""" zcml.load_string(zcml_text) manage_addDummySite(self.folder, 'site') enableLocalSiteHook(self.folder.site) setSite(self.folder.site)
def setup_zcml(): fiveconfigure.debug_mode = True import gomobile.convergence zcml.load_config('configure.zcml', gomobile.mobile) zcml.load_string(utils.ZCML_INSTALL_TEST_DISCRIMINATOR) fiveconfigure.debug_mode = False # We need to tell the testing framework that these products # should be available. This can't happen until after we have loaded # the ZCML. ztc.installPackage('gomobile.mobile') ztc.installPackage('gomobiletheme.basic')
def setUp(self): import Products.CMFCore TransactionalTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_string(_TRAVERSE_ZCML) root = self.root root._setObject('portal', DummyContent('portal', 'url_portal')) portal = self.portal = root.portal portal.portal_membership = DummyMembershipTool() self.folder = DummyContent('foo', 'url_foo') self.object = DummyContent('bar', 'url_bar')
def afterSetUp(self): super(ExportImportTester, self).afterSetUp() fiveconfigure.debug_mode = True try: zcml.load_string(zcml_string) except: pass fiveconfigure.debug_mode = False try: self.portal.portal_setup.runAllImportStepsFromProfile( 'profile-collective.easyform:testing') except: pass
def testWithDependency(self): zcml.load_string("""<configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="genericsetup"> <genericsetup:importStep name="name" title="title" description="description" handler="Products.GenericSetup.tests.test_zcml.dummy_importstep_handler"> <depends name="something.else"/> </genericsetup:importStep> </configure>""") data=_import_step_registry.getStepMetadata(u'name') self.assertEqual(data["dependencies"], (u"something.else",))
def setUp(cls): fiveconfigure.debug_mode = True zcml.load_string(zcml_string) fiveconfigure.debug_mode = False app = ZopeTestCase.app() portal = app.plone portal_setup = portal.portal_setup portal_setup.runAllImportStepsFromProfile('profile-collective.contentrules.mail:testing') commit() ZopeTestCase.close(app)
def test_vocabulary_includes_iviewview_viewlets(self): zcml.load_string('''\ <configure xmlns:browser="http://namespaces.zope.org/browser"> <browser:viewlet name="plone.dummyviewlet" manager="plone.app.layout.viewlets.interfaces.IBelowContentBody" class="plone.portlet.viewlet.tests.base.DummyViewlet" view="plone.app.layout.globals.interfaces.IViewView" permission="zope2.View" /> </configure>''') factory = getUtility(IVocabularyFactory, name='plone.portlet.viewlet.vocab') vocab = factory(self.folder) self.failUnless('plone.belowcontentbody plone.dummyviewlet' in vocab)
def afterSetUp(self): fiveconfigure.debug_mode = True zcml.load_config('configure.zcml', package=collective.beaker) zcml.load_string("""\ <configure package="collective.beaker" xmlns="http://namespaces.zope.org/browser"> <view name="session-test" for="*" class=".tests.SessionTestView" permission="zope2.View" /> </configure>""") fiveconfigure.debug_mode = False
def setUp(self): from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI SecurityTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.Five.browser) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_string(_TRAVERSE_ZCML) self.site = DummySite('site').__of__(self.root) self.acl_users = self.site._setObject( 'acl_users', DummyUserFolder() ) self.ttool = self.site._setObject( 'portal_types', self._makeOne() ) fti = FTIDATA_DUMMY[0].copy() self.ttool._setObject( 'Dummy Content', FTI(**fti) )
def setUp(self): from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI SecurityTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.Five.browser) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_string(_TRAVERSE_ZCML) self.site = DummySite('site').__of__(self.root) self.acl_users = self.site._setObject('acl_users', DummyUserFolder()) self.ttool = self.site._setObject('portal_types', self._makeOne()) fti = FTIDATA_DUMMY[0].copy() self.ttool._setObject('Dummy Content', FTI(**fti))
def setUp(cls): import Products.Five import Products.GenericSetup import Products.CMFCore import Products.CMFCore.exportimport import Products.DCWorkflow zcml.load_config('meta.zcml', Products.Five) zcml.load_config('configure.zcml', Products.Five) zcml.load_config('configure.zcml', Products.GenericSetup) zcml.load_config('tool.zcml', Products.CMFCore) zcml.load_config('configure.zcml', Products.CMFCore.exportimport) zcml.load_config('tool.zcml', Products.DCWorkflow) zcml.load_config('exportimport.zcml', Products.DCWorkflow) zcml.load_string(_DUMMY_ZCML)
def setUp(cls): fiveconfigure.debug_mode = True zcml.load_string(zcml_string) fiveconfigure.debug_mode = False app = ZopeTestCase.app() portal = app.plone portal_setup = portal.portal_setup portal_setup.runAllImportStepsFromProfile( 'profile-collective.contentrules.mail:testing') commit() ZopeTestCase.close(app)
def test_template(self): # test default template r = self.renderer( context=self.portal, assignment=ngcollection.Assignment(header=u"title", target_collection="/Members/test_user_1_/collection"), ) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless("portletCollection" in output) # test assigned custom testing template # register portlet templates directory with alternative template dir_path = path.join(path.dirname(__file__), "templates") zcml_string = ( """ <configure xmlns="http://namespaces.zope.org/zope" xmlns:plone="http://namespaces.plone.org/plone"> <include package="collective.portlet.ngcollection" file="meta.zcml" /> <plone:portletTemplates interface="collective.portlet.ngcollection.ngcollection.INGCollection" directory="%s" /> </configure> """ % dir_path ) fiveconfigure.debug_mode = True zcml.load_string(zcml_string) fiveconfigure.debug_mode = False t_path = path.join(dir_path, "test.pt") t_path = "%s:%s" % (dir_path, "test.pt") r = self.renderer( context=self.portal, assignment=ngcollection.Assignment( header=u"title", target_collection="/Members/test_user_1_/collection", template=t_path ), ) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless("This is a test template!" in output)
def afterSetUp(self): FeatureletsTestCase.afterSetUp(self) decl = """ <configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <browser:page for="topp.featurelets.tests.dummy.IDummyFeatureletInstalled" class="topp.featurelets.tests.dummy.DummyConfigView" permission="zope2.View" name="dummy_config" /> </configure> """ load_string(decl) self.featurelet = ConfigFeaturelet()
def setup_zcml(): fiveconfigure.debug_mode = True import emas.mobiletheme zcml.load_config('configure.zcml', emas.mobiletheme) # This test specific ZCML installation # will allow you to emulate different web and mobile browsers zcml.load_string(ZCML_INSTALL_TEST_DISCRIMINATOR) fiveconfigure.debug_mode = False # We need to tell the testing framework that these products # should be available. This can't happen until after we have loaded # the ZCML. ztc.installPackage('gomobile.mobile') ztc.installPackage('emas.mobiletheme')
def test_template(self): # test default template r = self.renderer( context=self.portal, assignment=ngcollection.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('portletCollection' in output) # test assigned custom testing template # register portlet templates directory with alternative template dir_path = path.join(path.dirname(__file__), 'templates') zcml_string = """ <configure xmlns="http://namespaces.zope.org/zope" xmlns:plone="http://namespaces.plone.org/plone"> <include package="collective.portlet.ngcollection" file="meta.zcml" /> <plone:portletTemplates interface="collective.portlet.ngcollection.ngcollection.INGCollection" directory="%s" /> </configure> """ % dir_path fiveconfigure.debug_mode = True zcml.load_string(zcml_string) fiveconfigure.debug_mode = False t_path = path.join(dir_path, 'test.pt') t_path = "%s:%s" % (dir_path, 'test.pt') r = self.renderer( context=self.portal, assignment=ngcollection.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection', template=t_path)) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('This is a test template!' in output)
def test_device_move(self): zcml.load_string(""" <configure xmlns="http://namespaces.zope.org/zope"> <adapter for="Products.ZenModel.Device.Device" provides="Products.ZenUtils.guid.interfaces.IGUIDManager" factory="Products.ZenUtils.guid.guid.GUIDManager" /> </configure> """) source = self.dmd.Devices.createOrganizer('source') dest = self.dmd.Devices.createOrganizer('dest') dev = source.createInstance('testdevice') guid = IGlobalIdentifier(dev).guid source.moveDevices(dest.getOrganizerName(), 'testdevice') newdev = dest.devices.testdevice newguid = IGlobalIdentifier(newdev).guid self.assertEqual(guid, newguid)
def testMultipleZCML(self): zcml.load_string('''\ <configure xmlns:transmogrifier="http://namespaces.plone.org/transmogrifier"> <transmogrifier:stylesheet source="marshall" from="Blog" to="Weblog" file="blog.xsl" /> <transmogrifier:stylesheet source="propertymanager" from="BlogEntry" to="WeblogEntry" file="blogentry.xsl" /> </configure>''') self.assertEqual(stylesheet_registry.listStylesheetNames(), (u'marshall:Blog:Weblog', u'propertymanager:BlogEntry:WeblogEntry'))
def testRegistration(self): zcml.load_string("""<configure xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="genericsetup"> <genericsetup:exportStep name="name" title="title" description="description" handler="Products.GenericSetup.tests.test_zcml.dummy_exportstep_handler" /> </configure> """) self.assertEqual( _export_step_registry.listSteps(), [u'name']) data=_export_step_registry.getStepMetadata(u'name') self.assertEqual(data["handler"], 'Products.GenericSetup.tests.test_zcml.dummy_exportstep_handler') self.assertEqual(data["description"], u"description") self.assertEqual(data["title"], u"title") self.assertEqual(data["id"], u"name")
def afterSetUp(self): setUp() from Products.Five.localsite import enableLocalSiteHook from Products.Five.testing.localsite import manage_addDummySite zcml.load_config("meta.zcml", Products.Five) zcml.load_config("localsite.zcml", Products.Five) zcml_text = """<configure xmlns:five="http://namespaces.zope.org/five"> <five:localsite class="Products.Five.testing.localsite.DummySite" /> </configure>""" zcml.load_string(zcml_text) manage_addDummySite(self.folder, 'site') self.site = self.folder.site self.site.manage_addFolder('utilities') self.utils = self.site.utilities enableLocalSiteHook(self.site) self.path = '/'.join(self.site.getPhysicalPath()) # Traverse to the site so that the local-thread site gets # setup correctly. self.publish(self.path)