Пример #1
0
 def create_patients_doctors(self,P,D):
     login_as_admin(self)
     for i in range(P):
         self.create_patient()
     for i in range(D):
         self.create_doctor()
     z2.logout()
Пример #2
0
    def setUpDefaultContent(self, app):

        """Add the site owner user to the root user folder and log in as that
        user. Create the Silva site.
        Note: There is no explicit tear-down of this setup operation, because
        all persistent changes are torn down when the stacked ZODB
        ``DemoStorage`` is popped.
        """

        # Create the owner user and "log in" so that the site object gets
        # the right ownership information
        app['acl_users'].userFolderAddUser(
            SITE_OWNER_NAME,
            SITE_OWNER_PASSWORD,
            ['Manager'],
            []
        )

        z2.login(app['acl_users'], SITE_OWNER_NAME)

        from Products.Silva.Root import manage_addRoot

        manage_addRoot(
            app, SILVA_SITE_ID,
            title=SILVA_SITE_TITLE,
        )

        # Log out again
        z2.logout()
Пример #3
0
    def setUpPloneSite(self, portal):
        from Products.CMFPlone import factory
        self.applyProfile(portal, factory._DEFAULT_PROFILE)
        self.applyProfile(portal, factory._CONTENT_PROFILE)
        getToolByName(portal, 'portal_css').setDebugMode(True)
        getToolByName(portal, 'portal_javascripts').setDebugMode(True)

        # Creates a user's home folder.
        membership = getToolByName(portal, 'portal_membership')
        if not membership.getMemberareaCreationFlag():
            membership.setMemberareaCreationFlag()
        membership.createMemberArea(testing.TEST_USER_ID)
        if membership.getMemberareaCreationFlag():
            membership.setMemberareaCreationFlag()
        folder = membership.getHomeFolder(testing.TEST_USER_ID)

        # Allow normal users to add collections.
        portal.manage_permission(
            'Add portal topics', roles=['Member', 'Manager'],
            acquire=0)

        self.applyProfile(portal, 'collective.formcriteria:default')
        self.applyProfile(portal, 'collective.formcriteria:testing')

        z2.login(portal.getPhysicalRoot().acl_users, testing.SITE_OWNER_NAME)
        getToolByName(portal, 'portal_workflow').doActionFor(folder, 'publish')
        z2.logout()
Пример #4
0
def CMFDefaultPortal(db=None, connection=None, environ=None):
    """Context manager for working with the Plone portal during layer setup::

        with CMFDefaultPortal() as portal:
            ...

    This is based on the ``z2.zopeApp()`` context manager. See the module
     ``plone.testing.z2`` for details.

    Do not use this in a test. Use the 'portal' resource from the PloneFixture
    layer instead!

    Pass a ZODB handle as ``db`` to use a specificdatabase. Alternatively,
    pass an open connection as ``connection`` (the connection will not be
    closed).
    """

    from zope.site.hooks import setSite, getSite, setHooks
    setHooks()

    site = getSite()

    with z2.zopeApp(db, connection, environ) as app:
        portal = app[SITE_ID]

        setSite(portal)
        z2.login(portal['acl_users'], TEST_USER_ID)

        try:
            yield portal
        finally:
            z2.logout()
            if site is not portal:
                setSite(site)
Пример #5
0
 def setUpPloneSite(self, portal):
     testing.login(portal, testing.TEST_USER_NAME)
     membership = getToolByName(portal, 'portal_membership')
     folder = membership.getHomeFolder(testing.TEST_USER_ID)
     foo_topic = folder[folder.invokeFactory(
         type_name='Topic', id='foo-topic-title',
         title='Foo Topic Title')]
     z2.login(portal.getPhysicalRoot().acl_users, testing.SITE_OWNER_NAME)
     portal.portal_workflow.doActionFor(foo_topic, 'publish')
     z2.logout()
Пример #6
0
    def tearDownEnvironment(self, portal):
        """Log out, invalidate standard RAM caches, and unset the local
        component site to clean up after tests.
        """

        # Clear the security manager
        z2.logout()

        # Unset the local component site
        from zope.site.hooks import setSite
        setSite(None)
Пример #7
0
    def setUp(self):
        self.app = self.layer['app']
        ZopeTestCase.utils.setupCoreSessions(self.app)
        self.app.REQUEST['SESSION'] = Session()
        
        self.portal = self.layer['portal']
        self.browser = Browser(self.app)

        z2.logout()
        z2.login(self.app['acl_users'], SITE_OWNER_NAME)
        create_members_by_debug_init(self)
Пример #8
0
 def setUpPloneSite(self, portal):
     self.applyProfile(
         portal, 'collective.formcriteria:formcriteria-columns')
     z2.login(portal.getPhysicalRoot().acl_users, testing.SITE_OWNER_NAME)
     membership = getToolByName(portal, 'portal_membership')
     folder = membership.getHomeFolder(testing.TEST_USER_ID)
     folder.manage_pasteObjects(
         portal.templates.manage_copyObjects(['Topic']))
     folder.manage_renameObject('Topic', 'foo-topic-title')
     foo_topic = folder['foo-topic-title']
     foo_topic.update(title='Foo Topic Title')
     z2.logout()
    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        getToolByName(portal, 'portal_quickinstaller').installProduct(
            'Products.ArchAddOn')
        self.applyProfile(portal, 'Products.PloneServicesCenter:default')

        # Publish the folders
        z2.login(aq_parent(portal).acl_users, 'admin')
        wftool = getToolByName(portal, 'portal_workflow')
        for id_ in ('case-studies', 'sites', 'providers'):
            wftool.doActionFor(portal.support[id_], 'publish')
        z2.logout()
    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        getToolByName(
            portal,
            'portal_quickinstaller').installProduct('Products.ArchAddOn')
        self.applyProfile(portal, 'Products.PloneServicesCenter:default')

        # Publish the folders
        z2.login(aq_parent(portal).acl_users, 'admin')
        wftool = getToolByName(portal, 'portal_workflow')
        for id_ in ('case-studies', 'sites', 'providers'):
            wftool.doActionFor(portal.support[id_], 'publish')
        z2.logout()
Пример #11
0
    def setUpDefaultContent(self, app):
        """Add the site owner user to the root user folder and log in as that
        user. Create the Plone site, installing the extension profiles listed
        in the ``extensionProfiles`` layer class variable. Create the test
        user inside the site, and disable the default workflow.

        Note: There is no explicit tear-down of this setup operation, because
        all persistent changes are torn down when the stacked ZODB
        ``DemoStorage`` is popped.
        """

        # Create the owner user and "log in" so that the site object gets
        # the right ownership information
        app['acl_users'].userFolderAddUser(
            SITE_OWNER_NAME,
            SITE_OWNER_PASSWORD,
            ['Manager'],
            []
        )

        z2.login(app['acl_users'], SITE_OWNER_NAME)

        # Create the site with the default set of extension profiles
        from Products.CMFPlone.factory import addPloneSite
        addPloneSite(
            app,
            PLONE_SITE_ID,
            title=PLONE_SITE_TITLE,
            setup_content=False,
            default_language=DEFAULT_LANGUAGE,
            extension_ids=self.extensionProfiles,
        )

        # Turn off default workflow
        app[PLONE_SITE_ID]['portal_workflow'].setDefaultChain('')

        # Create the test user. (Plone)PAS does not have an API to create a
        # user with different userid and login name, so we call the plugin
        # directly.
        pas = app[PLONE_SITE_ID]['acl_users']
        pas.source_users.addUser(
            TEST_USER_ID,
            TEST_USER_NAME,
            TEST_USER_PASSWORD
        )
        for role in TEST_USER_ROLES:
            pas.portal_role_manager.doAssignRoleToPrincipal(TEST_USER_ID, role)

        # Log out again
        z2.logout()
Пример #12
0
    def setUpDefaultContent(self, app):
        """Add the site owner user to the root user folder and log in as that
        user. Create the Plone site, installing the extension profiles listed
        in the ``extensionProfiles`` layer class variable. Create the test
        user inside the site, and disable the default workflow.

        Note: There is no explicit tear-down of this setup operation, because
        all persistent changes are torn down when the stacked ZODB
        ``DemoStorage`` is popped.
        """

        # Create the owner user and "log in" so that the site object gets
        # the right ownership information
        app['acl_users'].userFolderAddUser(
            SITE_OWNER_NAME,
            SITE_OWNER_PASSWORD,
            ['Manager'],
            []
        )

        z2.login(app['acl_users'], SITE_OWNER_NAME)

        # Create the site with the default set of extension profiles
        from Products.CMFPlone.factory import addPloneSite
        addPloneSite(
            app,
            PLONE_SITE_ID,
            title=PLONE_SITE_TITLE,
            setup_content=False,
            default_language=DEFAULT_LANGUAGE,
            extension_ids=self.extensionProfiles,
        )

        # Turn off default workflow
        app[PLONE_SITE_ID]['portal_workflow'].setDefaultChain('')

        # Create the test user. (Plone)PAS does not have an API to create a
        # user with different userid and login name, so we call the plugin
        # directly.
        pas = app[PLONE_SITE_ID]['acl_users']
        pas.source_users.addUser(
            TEST_USER_ID,
            TEST_USER_NAME,
            TEST_USER_PASSWORD
        )
        for role in TEST_USER_ROLES:
            pas.portal_role_manager.doAssignRoleToPrincipal(TEST_USER_ID, role)

        # Log out again
        z2.logout()
Пример #13
0
    def test_access_rights(self):
        # View access is required to traverse rapido view
        portal = api.portal.get()
        portal.manage_permission('View',
                                 roles=['Manager', 'Member', 'Authenticated'],
                                 acquire=0)
        portal.manage_setLocalRoles(TEST_USER_ID, ['Member'])

        login(portal, TEST_USER_NAME)
        self.assertTrue(portal.restrictedTraverse('@@rapido'))

        logout()
        with self.assertRaises(Unauthorized):
            portal.restrictedTraverse('@@rapido')
Пример #14
0
    def setUpPloneSite(self, portal):
        # Why the f...k do we need to run the standard workflow GS step?
        setuptool = portal['portal_setup']
        setuptool.runImportStepFromProfile('profile-Products.CMFPlone:plone',
                                           'workflow',
                                           run_dependencies=False)

        applyProfile(portal, 'plone.app.contenttypes:default')
        # Applying our default GS setup
        applyProfile(portal, 'aws.authrss:default')
        z2.login(portal.getParentNode().acl_users, SITE_OWNER_NAME)
        # Enabling global site syndication
        syntool = getToolByName(portal, 'portal_syndication')
        syntool.editProperties(isAllowed=True)
        z2.logout()
        login(portal, TEST_USER_NAME)
Пример #15
0
 def setUpDefaultContent_AdditionalPage(self, app, additional_page_id,
                                        additional_page_title):
     z2.login(app['acl_users'], SITE_OWNER_NAME)
     from Products.CMFPlone.factory import addPloneSite
     # Set up the second page with another ID here.
     addPloneSite(
         app,
         additional_page_id,
         title=additional_page_title,
         setup_content=False,
         default_language=DEFAULT_LANGUAGE,
         extension_ids=self.extensionProfiles,
     )
     app[additional_page_id]['portal_workflow'].setDefaultChain('')
     pas = app[additional_page_id]['acl_users']
     pas.source_users.addUser(TEST_USER_ID, TEST_USER_NAME,
                              TEST_USER_PASSWORD)
     for role in TEST_USER_ROLES:
         pas.portal_role_manager.doAssignRoleToPrincipal(TEST_USER_ID, role)
     z2.logout()
Пример #16
0
    def setUp(self):
        # Stack a new DemoStorage
        self['zodbDB'] = zodb.stackDemoStorage(
            self.get('zodbDB'), name='BundleLayer:%s' % self.language)

        with z2.zopeApp() as app:
            z2.login(app['acl_users'], SITE_OWNER_NAME)

            # instll a plone site with the bundle
            bundle = get_bundle_by_name('OneGov Box (Example content)')
            bundle.install(app, PLONE_SITE_ID, language=self.language)

            # create the plone test user
            pas = app[PLONE_SITE_ID]['acl_users']
            pas.source_users.addUser(
                    TEST_USER_ID,
                    TEST_USER_NAME,
                    TEST_USER_PASSWORD)
            for role in TEST_USER_ROLES:
                pas.portal_role_manager.doAssignRoleToPrincipal(TEST_USER_ID, role)

            z2.logout()
Пример #17
0
    def setUpPloneSite(self, portal):
        self.now = DateTime.DateTime(str(DateTime.DateTime())[:10])
        tomorrow = self.now + 1

        testing.login(portal, testing.TEST_USER_NAME)
        membership = getToolByName(portal, 'portal_membership')
        folder = membership.getHomeFolder(testing.TEST_USER_ID)
        foo_event = folder[folder.invokeFactory(
            type_name='Event', effectiveDate=self.now - 3,
            startDate=tomorrow, endDate=tomorrow,
            id='foo-event-title', title='Foo Event Title',
            creators='foo_creator_id', text='foo' * 2000)]
        bar_document = folder[folder.invokeFactory(
            type_name='Document', effectiveDate=self.now - 2,
            id='bar-document-title', title='Bar Document Title',
            description='blah', subject=['bah', 'qux'],
            creators='foo_creator_id', text='bar' * 1000)]
        bar_document.foo_int = 0
        baz_event = folder[folder.invokeFactory(
            type_name='Event', effectiveDate=self.now,
            id='baz-event-title', title='Baz Event Title',
            startDate=tomorrow, endDate=tomorrow,
            # More relevant for a "blah" search
            description='blah blah',
            subject=['qux', 'quux'],
            # BBB Plone 3, For Events eventType == subject
            eventType=['qux', 'quux'],
            creators='bar_creator_id')]
        baz_event.foo_int = 1

        z2.login(portal.getPhysicalRoot().acl_users, testing.SITE_OWNER_NAME)
        portal.portal_workflow.doActionFor(foo_event, 'publish')
        portal.portal_workflow.doActionFor(
            bar_document, 'publish')
        portal.portal_workflow.doActionFor(baz_event, 'publish')
        bar_document.setModificationDate(self.now)
        bar_document.reindexObject(['modification_date'])
        z2.logout()
Пример #18
0
    def setUpDefaultContent(self, app):
        """Add the site owner user to the root user folder and log in as that
        user. Create the CMFDefault site, installing the extension profiles
        listed in the ``extensionProfiles`` layer class variable. Create the
        test user inside the site.

        Note: There is no explicit tear-down of this setup operation, because
        all persistent changes are torn down when the stacked ZODB
        ``DemoStorage`` is popped.
        """

        # Create the owner user and "log in" so that the site object gets
        # the right ownership information
        app['acl_users'].userFolderAddUser(
                SITE_OWNER_NAME,
                SITE_OWNER_PASSWORD,
                ['Manager'],
                []
            )

        z2.login(app['acl_users'], SITE_OWNER_NAME)

        # Create the site with the default set of extension profiles
        from Products.CMFDefault.factory import addConfiguredSite
        addConfiguredSite(app, SITE_ID,
            "Products.CMFDefault:default")

        # Create the test user.
        app[SITE_ID]['acl_users'].userFolderAddUser(
                TEST_USER_ID,
                TEST_USER_PASSWORD,
                TEST_USER_ROLES,
                []
                )

        # Log out again
        z2.logout()
Пример #19
0
 def logout(self):
     z2.logout()
     self.current_user = None
 def tearDown(self):
     """Logout."""
     super(TestPortlet, self).tearDown()
     z2.logout()
Пример #21
0
def logout():
    """Log out, i.e. become anonymous
    """

    z2.logout()
Пример #22
0
 def tearDown(self):
     """Logout."""
     super(TestPortlet, self).tearDown()
     z2.logout()
Пример #23
0
    def test_migration(self):
        # cf1
        portal = self.layer['portal']
        z2.login(portal['acl_users'], 'manager')
        portal.invokeFactory("Child Folder", "cf1")
        cf1 = portal.cf1
        cf1.setTitle("CF 1")
        cf1.setDescription("Description of CF 1")
        cf1.layout = "layout1"
        pw = portal.portal_workflow
        pw.doActionFor(cf1, "publish")
        self.failUnless(cf1.Title() == "CF 1")
        self.failUnless(cf1.Description() == "Description of CF 1")
        self.failUnless(pw.getInfoFor(cf1, "review_state") == "published")
        self.failUnless(cf1.layout == "layout1")

        cf1.invokeFactory("Document", "doc1")
        cf1.invokeFactory("Document", "doc2")
        doc1 = cf1["doc1"]
        doc1.setTitle("Doc 1")
        doc1.setDescription("Description of Doc 1")
        doc1.setText("<p>Some Text here</p>")

        # cf2
        portal.invokeFactory("Child Folder", "cf2")
        cf2 = portal.cf2

        #cf3
        cf2.invokeFactory("Child Folder", "cf3")
        cf3 = cf2.cf3
        cf3.setTitle("CF 3")
        cf3.setDescription("Description of CF 3")
        cf3.layout = "3layout"
        pw.doActionFor(cf3, "publish")
        self.failUnless(cf3.Title() == "CF 3")
        self.failUnless(cf3.Description() == "Description of CF 3")
        self.failUnless(pw.getInfoFor(cf3, "review_state") == "published")

        cf3.invokeFactory("Document", "doc1")
        cf3.invokeFactory("Document", "doc2")
        doc1 = cf3["doc1"]
        doc1.setTitle("Doc 1")
        doc1.setDescription("Description of Doc 1")
        doc1.setText("<p>Some Text here</p>")

        self.run_migration_step()

        # then we test if cf1-3 are still existing
        # but are just normal folder that are subtyped
        # also check they still have the correct title
        # description, content, state and layout
        cf1 = portal.cf1
        cf2 = portal.cf2
        cf3 = cf2.cf3
        doc1 = cf3.doc1
        self.failUnless(cf1.Title() == "CF 1")
        self.failUnless(pw.getInfoFor(cf1, "review_state") == "published")
        self.failUnless(cf1.layout == "layout1")
        self.failUnless(cf3.Title() == "CF 3")
        self.failUnless(cf3.Description() == "Description of CF 3")
        self.failUnless(cf3.layout == "3layout")
        self.failUnless(pw.getInfoFor(cf3, "review_state") == "published")
        self.failUnless(cf1.portal_type == "Folder")
        self.failUnless(cf3.portal_type == "Folder")
        self.failUnless(doc1.getRawText() == "<p>Some Text here</p>")

        #check that anonymous can see the published items
        z2.logout()
        try:
            cf1_item = portal.restrictedTraverse("cf1")
        except Unauthorized:
            cf1_item = None
        self.failUnless(cf1_item != None)
Пример #24
0
def logout():
    """Log out, i.e. become anonymous
    """

    z2.logout()