def setUpPloneSite(self, portal): applyProfile( portal, 'Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow') applyProfile(portal, 'ftw.upgrade:default') setRoles(portal, TEST_USER_ID, ['Manager']) login(portal, TEST_USER_NAME)
def test_install(self): """When p.app.intid is intalled it registers some utility from zope.intid and five.intid and search in portal_catalog all contents in order to register them in these utilities. This test checks that all pre existing contents are registered correctly """ from plone.app.intid.setuphandlers import add_intids from plone.app.testing import applyProfile # we create a folder before the intallation of plone.app.intid setRoles(self.portal, TEST_USER_ID, ['Manager']) folder_id = self.portal.invokeFactory('Folder', 'folder') folder = self.portal[folder_id] # now we install manually the intid utilities add_intids(self.portal) intids = getUtility(IIntIds) # this folder is not referenced by intid utility self.assertRaises(KeyError, intids.getId, folder) # when we install p.app.intid our folder is referencend by intid applyProfile(self.portal, 'plone.app.intid:default') self.assertIsNotNone(intids.getId(folder))
def test_ATPathCriterionMultiNonRecursive(self): # Collections support multiple paths since # plone.app.querystring 1.2.0. login(self.portal, 'admin') self.portal.invokeFactory('Folder', 'folder2', title='Folder 2') crit = self.add_criterion( 'path', 'ATPathCriterion', [self.portal.folder.UID(), self.portal.folder2.UID()] ) crit.setRecurse(False) applyProfile(self.portal, 'plone.app.contenttypes:default') self.run_migration() query = self.portal.topic.query self.assertEqual(len(query), 2) self.assertEqual(query[0], {'i': 'path', 'o': 'plone.app.querystring.operation.string.path', 'v': self.portal.folder.UID() + '::1'}) self.assertEqual(query[1], {'i': 'path', 'o': 'plone.app.querystring.operation.string.path', 'v': self.portal.folder2.UID() + '::1'}) # Check that the resulting query does not give an error. self.portal.topic.results
def setUpPloneSite(self, portal): applyProfile(portal, 'abstract.portletface:default') setRoles(portal, TEST_USER_ID, ['Manager']) self.doc_id = portal.invokeFactory('Document', 'test_document') self.folder_id = portal.invokeFactory('Folder', 'test_folder') setRoles(portal, TEST_USER_ID, ['Member'])
def test_ATSelectionCriterion(self): # The new-style queries do not currently offer the possibility # to choose if the given values should be joined with 'or' or # 'and'. Default is 'or'. crit = self.add_criterion( 'Subject', 'ATSelectionCriterion', ('foo', 'bar') ) crit.setOperator('or') # Note: this could have been an ATPortalTypeCriterion too: # Note that we check that Topic is turned into Collection too. crit = self.add_criterion( 'portal_type', 'ATSelectionCriterion', ('Document', 'Topic') ) crit.setOperator('and') applyProfile(self.portal, 'plone.app.contenttypes:default') self.run_migration() query = self.portal.topic.query self.assertEqual(len(query), 2) self.assertEqual(query[0], {'i': 'Subject', 'o': 'plone.app.querystring.operation.selection.any', 'v': ('foo', 'bar')}) self.assertEqual(query[1], {'i': 'portal_type', 'o': 'plone.app.querystring.operation.selection.any', 'v': ('Document', 'Collection')}) # Check that the resulting query does not give an error. self.portal.topic.results
def setUp(self): """Shared test environment set-up, ran before every test.""" layer = self.globs["layer"] # Update global variables within the tests. self.globs.update( { "portal": layer["portal"], "request": layer["request"], "browser": Browser(layer["app"]), "TEST_USER_NAME": TEST_USER_NAME, "TEST_USER_PASSWORD": TEST_USER_PASSWORD, "self": self, } ) portal = self.globs["portal"] browser = self.globs["browser"] browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ["Manager"]) applyProfile(portal, "Products.CMFPlone:plone") transaction.commit()
def setUpPloneSite(self, portal): """ Setup Plone """ applyProfile(portal, 'eea.app.visualization:default') # Login as manager setRoles(portal, TEST_USER_ID, ['Manager'])
def setUpPloneSite(self, portal): self.registerVocabularies() applyProfile(portal, 'plone.app.collection:default') applyProfile(portal, 'archetypes.querywidget:test_fixture') portal.acl_users.userFolderAddUser('admin', 'secret', ['Manager'], []) login(portal, 'admin') # enable workflow for browser tests workflow = portal.portal_workflow workflow.setDefaultChain('simple_publication_workflow') # add a page, so we can test with it portal.invokeFactory("Document", "document", title="Document Test Page") # and add a collection so we can test the widget portal.invokeFactory("Collection", "collection", title="Test Collection") workflow.doActionFor(portal.document, "publish") workflow.doActionFor(portal.collection, "publish")
def install_profiles(self): """Installes additional generic setup profile. """ portal = self.layer['portal'] for profile in self.profiles: applyProfile(portal, profile)
def setUp(self): self.portal = self.layer['portal'] self.portal.portal_workflow.setDefaultChain( 'simple_publication_workflow') applyProfile(self.portal, 'plone.app.contenttypes:plone-content') self.document = api.content.create( container=self.portal, type='Document', title='Doc', language='en')
def setUp(self): import collective.js.speakjs xmlconfig.file('configure.zcml', collective.js.speakjs, context=self['configurationContext']) with ploneSite() as portal: applyProfile(portal, 'collective.js.speakjs:default')
def test_collectivetask_is_dependency_of_imio_schedule(self): """ collective.task should be installed when we install imio.schedule """ self.assertTrue(not self.installer.isProductInstalled('collective.task')) applyProfile(self.portal, 'imio.schedule:default') self.assertTrue(self.installer.isProductInstalled('collective.task'))
def setUpPloneSite(self, portal): self['portal'] = portal applyProfile(portal, 'collective.lineage:default') roles = ('Member', 'Manager') portal.portal_membership.addMember('manager', 'secret', roles, []) roles = ('Member', 'Contributor') portal.portal_membership.addMember('contributor', 'secret', roles, [])
def test_dexterity_is_dependency_of_imio_schedule(self): """ dexterity should be installed when we install imio.schedule """ self.assertTrue(not self.installer.isProductInstalled('plone.app.dexterity')) applyProfile(self.portal, 'imio.schedule:default') self.assertTrue(self.installer.isProductInstalled('plone.app.dexterity'))
def test_z3cformdatagridfield_is_dependency_of_imio_schedule(self): """ z3cform.datagridfield should be installed when we install imio.schedule """ self.assertTrue(not self.installer.isProductInstalled('collective.z3cform.datagridfield')) applyProfile(self.portal, 'imio.schedule:default') self.assertTrue(self.installer.isProductInstalled('collective.z3cform.datagridfield'))
def setUpPloneSite(self, portal): # Install into Plone site using portal_setup applyProfile(portal, 'plone.app.discussion:default') # Creates some users acl_users = getToolByName(portal, 'acl_users') acl_users.userFolderAddUser( self.USER_NAME, self.USER_PASSWORD, [], [], ) acl_users.userFolderAddUser( self.MEMBER_NAME, self.MEMBER_PASSWORD, ['Member'], [], ) acl_users.userFolderAddUser( self.USER_WITH_FULLNAME_NAME, self.USER_WITH_FULLNAME_PASSWORD, ['Member'], [], ) mtool = getToolByName(portal, 'portal_membership', None) mtool.addMember('jim', 'Jim', ['Member'], []) mtool.getMemberById('jim').setMemberProperties({"fullname": 'Jim Fult\xc3\xb8rn'}) acl_users.userFolderAddUser( self.MANAGER_USER_NAME, self.MANAGER_USER_PASSWORD, ['Manager'], [], )
def setUpPloneSite(self, portal): login(portal.aq_parent, SITE_OWNER_NAME) wf = getToolByName(portal, 'portal_workflow') wf.setDefaultChain('plone_workflow') setupPortalContent(portal) # make sure we have folder_listing as a template portal.getTypeInfo().manage_changeProperties( view_methods=['folder_listing'], default_view='folder_listing') applyProfile(portal, 'bika.lims:default') # Add some test users for role in ('LabManager', 'LabClerk', 'Analyst', 'Verifier', 'Sampler', 'Preserver', 'Publisher', 'Member', 'Reviewer', 'RegulatoryInspector'): for user_nr in range(2): if user_nr == 0: username = "******" % (role.lower()) else: username = "******" % (role.lower(), user_nr) try: member = portal.portal_registration.addMember( username, username, properties={ 'username': username, 'email': username + "@example.com", 'fullname': username} ) # Add user to all specified groups group_id = role + "s" group = portal.portal_groups.getGroupById(group_id) if group: group.addMember(username) # Add user to all specified roles member._addRole(role) # If user is in LabManagers, add Owner local role on clients folder if role == 'LabManager': portal.clients.manage_setLocalRoles(username, ['Owner', ]) except ValueError: pass # user exists # Force the test browser to show the site always in 'en' ltool = portal.portal_languages ltool.manage_setLanguageSettings('en', ['en'], setUseCombinedLanguageCodes=False, startNeutral=True) logout()
def setUp(self): self.settings = getUtility(IRegistry).forInterface(IThemeSettings) self.settings.enabled = True self.settings.rules = u'python://plone.app.theming/tests/rules.xml' self.settings.parameterExpressions = { 'stringParam': 'string:string param value', 'boolParam': 'python:False', 'contextParam': 'context/absolute_url | string:no context', 'requestParam': 'request/useother | string:off', } self.portal = self.layer['portal'] setRequest(self.portal.REQUEST) applyProfile(self.portal, 'plone.app.caching:without-caching-proxy') self.cacheSettings = getUtility(IRegistry).forInterface(ICacheSettings) self.cacheSettings.enabled = True self.cacheSettings.operationMapping = { 'plone.content.folderView': 'plone.app.caching.weakCaching'} registry = getUtility(IRegistry) registry['plone.app.caching.weakCaching.ramCache'] = True import transaction transaction.commit()
def setUp(self): # pragma: no cover """Shared test environment set-up, ran before every test.""" layer = self.globs['layer'] # Update global variables within the tests. self.globs.update({ 'portal': layer['portal'], 'request': layer['request'], 'browser': Browser(layer['app']), 'TEST_USER_NAME': TEST_USER_NAME, 'TEST_USER_PASSWORD': TEST_USER_PASSWORD, 'self': self, }) portal = self.globs['portal'] browser = self.globs['browser'] browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ['Manager']) applyProfile(portal, 'Products.CMFPlone:plone') # Plone 5 support if HAS_PA_CONTENTTYPES: applyProfile(portal, 'plone.app.contenttypes:default')
def setUpPloneSite(self, portal): # install into the Plone site applyProfile(portal, 'plone.app.toolbar:default') # applyProfile(portal, 'plone.app.toolbar:testfixture') workflowTool = getToolByName(portal, 'portal_workflow') workflowTool.setDefaultChain('plone_workflow') # Don't ignore exceptions so that problems don't hide behind # Unauthorized or NotFound exceptions when doing functional # testing. error_log = getToolByName(portal, 'error_log') error_props = error_log.getProperties() error_props['ignored_exceptions'] = ('Redirect',) error_props = error_log.setProperties( **error_props) # Put resource registries in debug mode to make it easier to # inspect CSS, JavaScript, and KSS getToolByName(portal, 'portal_css').setDebugMode(True) getToolByName(portal, 'portal_javascripts').setDebugMode(True) getToolByName(portal, 'portal_kss').setDebugMode(True) # set up content required for acceptance tests login(portal, TEST_USER_NAME) setRoles(portal, TEST_USER_ID, ['Manager', ]) afid = portal.invokeFactory( 'Folder','acceptance-test-folder', title='Acceptance Test Folder')
def setUpPloneSite(self, portal): applyProfile(portal, "plone.app.imagecropping:testing") portal.acl_users.userFolderAddUser("admin", "secret", ["Manager"], []) login(portal, "admin") portal.portal_workflow.setDefaultChain("simple_publication_workflow") setRoles(portal, TEST_USER_ID, ["Manager"]) portal.invokeFactory("Folder", id="acceptance-test-folder", title=u"Test Folder")
def setUpPloneSite(self, portal): # Install into Plone site using portal_setup applyProfile(portal, 'collective.contentrules.subscription:default') setRoles(portal, TEST_USER_ID, ['Member', 'Manager']) portal.invokeFactory('Folder', 'folder-1', title="Folder 1")
def setUpPloneSite(self, portal): # install into the Plone site applyProfile(portal, 'plone.app.toolbar:default') workflowTool = getToolByName(portal, 'portal_workflow') workflowTool.setDefaultChain('plone_workflow') # Don't ignore exceptions so that problems don't hide behind # Unauthorized or NotFound exceptions when doing functional # testing. error_log = getToolByName(portal, 'error_log') error_props = error_log.getProperties() error_props['ignored_exceptions'] = ('Redirect',) error_props = error_log.setProperties( **error_props) # Put resource registries in debug mode to make it easier to # inspect CSS and JavaScript getToolByName(portal, 'portal_css').setDebugMode(True) getToolByName(portal, 'portal_javascripts').setDebugMode(True) login(portal, TEST_USER_NAME) portal.portal_workflow.setDefaultChain("simple_publication_workflow") setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory( "Folder", id="test-folder", title=u"Test Folder" )
def test_show_on_home_field_is_protected(self, browser): applyProfile(self.portal, 'ftw.news:show-on-homepage') page = create(Builder('sl content page')) newsfolder = create(Builder('news folder').within(page)) news = create(Builder('news') .within(newsfolder) .having(news_date=datetime(2011, 1, 2, 15, 0, 0))) field_label = 'Show on home page' browser.login().visit(news, view='edit') self.assertIn( field_label, browser.forms['form'].field_labels, "The manager must be able to mark news to be shown on the" "homepage," ) user = create(Builder('user').with_roles('Editor')) browser.login(user).visit(news, view='edit') self.assertNotIn( field_label, browser.forms['form'].field_labels, "An editor must not be able to mark news to be shown on the" "homepage." )
def test_show_on_home_factory_does_not_remove_other_interfaces(self): applyProfile(self.portal, 'ftw.news:show-on-homepage') page = create(Builder('sl content page')) newsfolder = create(Builder('news folder').within(page)) news = create(Builder('news') .within(newsfolder) .having(news_date=datetime(2011, 1, 2, 15, 0, 0))) class IDummyMarkerInterface(Interface): pass directlyProvides(news, IDummyMarkerInterface) self.assertEqual( [IDummyMarkerInterface], list(directlyProvidedBy(news)) ) IShowOnHomepageSchema(news).show_on_homepage = True self.assertEqual( [IDummyMarkerInterface, IShowOnHomepage], list(directlyProvidedBy(news)) ) IShowOnHomepageSchema(news).show_on_homepage = False self.assertEqual( [IDummyMarkerInterface], list(directlyProvidedBy(news)) )
def setUpPloneSite(self, portal): # Define available languages before installing PAM # This simulates the behavior of having predefined languages # in GenericSetup before installing PAM language_tool = getToolByName(portal, 'portal_languages') language_tool.addSupportedLanguage('ca') language_tool.addSupportedLanguage('es') # Enable request negotiator language_tool.use_request_negotiation = True # Activate product applyProfile(portal, 'plone.app.multilingual:default') # Empower test user setRoles(portal, TEST_USER_ID, ['Manager']) # Enable all errors error_log = getToolByName(portal, 'error_log') error_log._ignored_exceptions = () # Set default workflow wftool = getToolByName(portal, 'portal_workflow') wftool.setDefaultChain('simple_publication_workflow') # Cleanup p.a.contenttypes stuff if 'robot-test-folder' in portal.objectIds(): portal.manage_delObjects('robot-test-folder')
def setUpPloneSite(self, portal): applyProfile(portal, 'Products.CMFPlomino:default') setRoles(portal, TEST_USER_ID, ['Manager', 'Member']) login(portal, TEST_USER_NAME) db = api.content.create( type='PlominoDatabase', id='mydb', title='mydb', container=portal) frm_test = api.content.create( type='PlominoForm', id='frm_test', title='Form 1', container=db) frm_test.form_layout = """<p>please enter a value for field_1: <span class="plominoFieldClass">field_1</span></p>""" field_1 = api.content.create( type='PlominoField', id='field_1', title='field_1', container=frm_test) field_1.field_type = "TEXT" field_1.field_mode = "EDITABLE" db.createDocument("doc1")
def setUpPloneSite(self, portal): applyProfile(portal, 'plone.app.contenttypes:default') # install and enable referenceablebehavior on Documents to be able to # test controlpanel to enable plone.app.linkintegrity checks # XXX Disabled as it is causing test errors in comments # see https://github.com/plone/Products.CMFPlone/issues/255 # applyProfile(portal, 'plone.app.referenceablebehavior:default') # portal.portal_types.Document.behaviors += \ # ('plone.app.referenceablebehavior.referenceable.IReferenceable',) mtr = portal.mimetypes_registry mime_doc = mtr.lookup('application/msword')[0] mime_doc.icon_path = 'custom.png' portal.acl_users.userFolderAddUser('admin', 'secret', ['Manager'], []) login(portal, 'admin') portal.portal_workflow.setDefaultChain("simple_publication_workflow") setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory( "Folder", id=TEST_FOLDER_ID, title=u"Test Folder" )
def setUpPloneSite(self, portal): wftool = getToolByName(portal, 'portal_workflow') wftool.setChainForPortalTypes(['ExampleDxType'], 'simple_publication_workflow') applyProfile(portal, 'ftw.inflator:setup-language') applyProfile(portal, 'ftw.inflator.tests:dx_creation')
def setUpPloneSite(self, portal): applyProfile(portal, 'rer.sitesearch:default') setRoles(portal, TEST_USER_ID, ['Member', 'Manager']) for i in range(0, 80): """ create some documents """ portal.invokeFactory('Document', 'my-page' + str(i), title='My page %s' % str(i), text='spam spam ham eggs') for i in range(0, 5): """ create some news with a Subject """ portal.invokeFactory('News Item', 'my-news' + str(i), title='My news %s' % str(i), text='spam chocolate ham eggs', subject=('apple', 'mango')) for i in range(0, 5): """ create some documents with a Subject """ portal.invokeFactory('Document', 'categorized-page' + str(i), title='Categorized page %s' % str(i), text='spam chocolate ham eggs', subject=('apple', 'kiwi'))
def setUpPloneSite(self, portal): applyProfile(portal, 'rg.prenotazioni:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'plonetraining.testing:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'nva.praeventionswissen:default')
def setUpPloneSite(self, portal): applyProfile(portal, "pst.restapi:default")
def setUpPloneSite(self, portal): applyProfile(portal, 'collective.archetypes.select2:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'ploneintranet.activitystream:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'tx.tiles:default') setRoles(portal, TEST_USER_ID, ('Member', 'Manager')) workflowTool = getToolByName(portal, 'portal_workflow') workflowTool.setDefaultChain('plone_workflow')
def setUpPloneSite(self, portal): applyProfile(portal, 'taiwananthro.content:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'collective.conference:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'isaw.policy:default')
def test_installation(self): portal = self.layer['portal'] applyProfile(portal, 'collective.geotransform:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'training.myaddon:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'odfauthors.policy:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'collective.discussion.mentioning:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'zettwerk.mobiletheming:default')
def setUpPloneSite(self, portal): # install plone.resource applyProfile(portal, 'plone.resource:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'plone.formwidget.masterselect:demo')
def setUpPloneSite(self, portal): applyProfile(portal, 'rohberg.expertsearch:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'cshm.content:default')
def setUpPloneSite(self, portal): portal.portal_properties.site_properties.webstats_js = 'SITE DEFAULT ANALYTICS' applyProfile(portal, 'collective.analyticspanel:default') #quickInstallProduct(portal, 'collective.analyticspanel') setRoles(portal, TEST_USER_ID, ['Member', 'Manager'])
def setUpPloneSite(self, portal): super(AsyncMustreadLayer, self).setUpPloneSite(portal) applyProfile(portal, 'collective.mustread:default')
def setUpPloneSite(self, portal): applyProfile(portal,'edeposit.policy:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'misitio.policy:default') applyProfile(portal, 'Products.CMFPlacefulWorkflow:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'spirit.plone.stripe:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'rohberg.joomlamigration:default')
def setUpPloneSite(self, portal): """Set up Plone.""" # Install into Plone site using portal_setup applyProfile(portal, 'ploneintranet.async:default') applyProfile(portal, 'ploneintranet.docconv.client:default') setRoles(portal, TEST_USER_ID, ['Manager'])
def setUpPloneSite(self, portal): applyProfile(portal, 'plonetheme.booster:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'collective.qualitycheck:default')
def setUpPloneSite(self, portal): applyProfile(portal, 'parruc.devtools:default')
def setUpPloneSite(self, portal): # Install into Plone site using portal_setup applyProfile(portal, 'collective.panels:default')