Ejemplo n.º 1
0
 def test_can_enter_expiry_date(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "effective_date_transition_doc", delete_first=True, title="Workflow note")
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     browser.getLink("Public draft").click()
     workflow_actions = browser.getControl(name="form.widgets.workflow_action:list")
     workflow_actions.getControl(value="publish").click()
     # We set up a comment this time
     
     next_year = datetime.now() + timedelta(365)
     next_year = next_year - timedelta(seconds=next_year.second,
                                     microseconds=next_year.microsecond)
     browser.getControl(name="form.widgets.expiration_date-day").value = str(next_year.day)
     browser.getControl(name="form.widgets.expiration_date-month").value = [str(next_year.month)]
     browser.getControl(name="form.widgets.expiration_date-year").value = str(next_year.year)
     browser.getControl(name="form.widgets.expiration_date-hour").value = str(next_year.hour)
     browser.getControl(name="form.widgets.expiration_date-min").value = str(next_year.minute)
     browser.getControl("Save").click()
     
     # and it shows up in the workflow history
     self.assertEqual("publish", document.workflow_history['plone_workflow'][-1]['action'])
     self.assertEqual("published", portal.portal_workflow.getInfoFor(document, "review_state"))
     self.assertEqual(DateTime(next_year), document.getRawExpirationDate())
     
     portal.manage_delObjects(['effective_date_transition_doc'])
Ejemplo n.º 2
0
 def test_delete_existence(self):
     setRoles(self.layer['portal'], TEST_USER_ID, ['Owner'])
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/key-party/he/@@cmsui-menu')
     self.assertTrue(
         browser.getLink('Delete').url.endswith('he/delete_confirmation'))
Ejemplo n.º 3
0
 def test_can_enter_expiration_date_without_transaction(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "expiration_date_without_transition_doc", delete_first=True, title="Workflow note")
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     browser.getLink("Public draft").click()
     
     # Don't select any workflow action, but set date
     next_year = datetime.now() + timedelta(365)
     next_year = next_year - timedelta(seconds=next_year.second,
                                     microseconds=next_year.microsecond)
     browser.getControl(name="form.widgets.expiration_date-day").value = str(next_year.day)
     browser.getControl(name="form.widgets.expiration_date-month").value = [str(next_year.month)]
     browser.getControl(name="form.widgets.expiration_date-year").value = str(next_year.year)
     browser.getControl(name="form.widgets.expiration_date-hour").value = str(next_year.hour)
     browser.getControl(name="form.widgets.expiration_date-min").value = str(next_year.minute)
     browser.getControl("Save").click()
     
     # Still draft, but expiration date set
     self.assertEqual("visible", portal.portal_workflow.getInfoFor(document, "review_state"))
     self.assertEqual(DateTime(next_year), document.getRawExpirationDate())
Ejemplo n.º 4
0
 def test_available_workflow_transition_shown_in_workflow_panel(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "transition_shown_in_workflow_panel_doc", delete_first=True, title="Workflow transitions")
     # Commit so the change in roles is visible to the browser
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     browser.getLink("Public draft").click()
     
     # The submit button should be available
     transitions = portal.portal_workflow.getTransitionsFor(document)
     transition_ids = [transition['id'] for transition in transitions]
     # Ensure the workflow transition we are going to look for in the
     # workflow panel is actually available to save debugging headaches
     # later
     self.assertEqual(sorted(['submit', 'hide', 'publish']), sorted(transition_ids))
     
     # Make sure we have both labels and values for all possible workflow actions
     workflow_actions = browser.getControl(name="form.widgets.workflow_action:list")
     self.assertEqual(len(workflow_actions.mech_control.items),3)
     self.assertEqual(workflow_actions.getControl(label='Submit for publication').optionValue, 'submit')
     self.assertEqual(workflow_actions.getControl(label='Make private').optionValue, 'hide')
     self.assertEqual(workflow_actions.getControl(label='Publish').optionValue, 'publish')
    def test_can_enter_changenote(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "changenote_transition_doc",
                                delete_first=True,
                                title="Workflow note")
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        browser.getLink("Public draft").click()
        workflow_actions = browser.getControl(
            name="form.widgets.workflow_action:list")
        workflow_actions.getControl(value="publish").click()
        # We set up a comment this time
        browser.getControl(name="form.widgets.comment").value = "wibble fkjwel"
        browser.getControl("Save").click()

        # and it shows up in the workflow history
        self.assertEqual(
            "publish",
            document.workflow_history['plone_workflow'][-1]['action'])
        self.assertEqual(
            "wibble fkjwel",
            document.workflow_history['plone_workflow'][-1]['comments'])
Ejemplo n.º 6
0
 def test_sharing_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('document-author' not in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Editor'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('document-author' in browser.contents)
Ejemplo n.º 7
0
 def test_history_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('document-history' not in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Editor'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('document-history' in browser.contents)
Ejemplo n.º 8
0
 def test_site_setup_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('site-setup' not in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Manager'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('site-setup' in browser.contents)
Ejemplo n.º 9
0
 def test_site_setup_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('site-setup' not in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Manager'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('site-setup' in browser.contents)
Ejemplo n.º 10
0
    def test_table_headers_hidden_on_empty_folder(self):
        browser_login(self.portal, self.browser)
        
        # empty folder
        self.browser.open('http://nohost/plone/empty-folder/cmsui-structure')
        self.assertFalse('foldercontents-title-column' in self.browser.contents)

        # non-empty folder
        self.browser.open('http://nohost/plone/cmsui-structure')
        self.assertTrue('foldercontents-title-column' in self.browser.contents)
Ejemplo n.º 11
0
 def test_workflow_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('plone-contentmenu-workflow' not in browser.contents)
     self.assertTrue('Status:' in browser.contents)
     self.assertTrue('Public draft' in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Reviewer'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('plone-contentmenu-workflow' in browser.contents)
Ejemplo n.º 12
0
 def test_workflow_button_permission(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('plone-contentmenu-workflow' not in browser.contents)
     self.assertTrue('Status:' in browser.contents)
     self.assertTrue('Public draft' in browser.contents)
     setRoles(self.portal, TEST_USER_ID, ['Member', 'Reviewer'])
     transaction.commit()
     browser.open('http://nohost/plone/empty-folder/cmsui-menu')
     self.assertTrue('plone-contentmenu-workflow' in browser.contents)
Ejemplo n.º 13
0
    def test_table_headers_hidden_on_empty_folder(self):
        browser_login(self.portal, self.browser)

        # empty folder
        self.browser.open('http://nohost/plone/empty-folder/cmsui-structure')
        self.assertFalse(
            'foldercontents-title-column' in self.browser.contents)

        # non-empty folder
        self.browser.open('http://nohost/plone/cmsui-structure')
        self.assertTrue('foldercontents-title-column' in self.browser.contents)
Ejemplo n.º 14
0
 def test_panel_linked_to_in_menu(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     # Commit so the change in roles is visible to the browser
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(portal.absolute_url())
     browser.getLink("Manage page").click()
     
     # raises exception if not present
     browser.getLink("Workflow actions").click()
     self.assertIn("form.widgets.workflow_action", browser.contents) #TODO: Should have something less magical to check for
    def test_can_enter_expiry_date(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "effective_date_transition_doc",
                                delete_first=True,
                                title="Workflow note")
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        browser.getLink("Public draft").click()
        workflow_actions = browser.getControl(
            name="form.widgets.workflow_action:list")
        workflow_actions.getControl(value="publish").click()
        # We set up a comment this time

        next_year = datetime.now() + timedelta(365)
        next_year = next_year - timedelta(seconds=next_year.second,
                                          microseconds=next_year.microsecond)
        browser.getControl(
            name="form.widgets.expiration_date-day").value = str(next_year.day)
        browser.getControl(name="form.widgets.expiration_date-month").value = [
            str(next_year.month)
        ]
        browser.getControl(
            name="form.widgets.expiration_date-year").value = str(
                next_year.year)
        browser.getControl(
            name="form.widgets.expiration_date-hour").value = str(
                next_year.hour)
        browser.getControl(
            name="form.widgets.expiration_date-min").value = str(
                next_year.minute)
        browser.getControl("Save").click()

        # and it shows up in the workflow history
        self.assertEqual(
            "publish",
            document.workflow_history['plone_workflow'][-1]['action'])
        self.assertEqual(
            "published",
            portal.portal_workflow.getInfoFor(document, "review_state"))
        self.assertEqual(DateTime(next_year), document.getRawExpirationDate())

        portal.manage_delObjects(['effective_date_transition_doc'])
Ejemplo n.º 16
0
 def test_panel_linked_to_in_menu(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "panel_linked_to_in_menu_doc", delete_first=True, title="Workflow transitions")
     # Commit so the change in roles is visible to the browser
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     
     # raises exception if not present
     browser.getLink("Public draft").click()
     self.assertIn("form.widgets.workflow_action", browser.contents)
Ejemplo n.º 17
0
 def test_choosing_transition_transitions_content(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "do_workflow_transition_doc", delete_first=True, title="Workflow transitioning")
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     browser.getLink("Public draft").click()
     workflow_actions = browser.getControl(name="form.widgets.workflow_action:list")
     workflow_actions.getControl(value="publish").click()
     browser.getControl("Save").click()
     
     self.assertEqual("published", portal.portal_workflow.getInfoFor(document, "review_state"))
Ejemplo n.º 18
0
    def test_menu_sublinks_rendered_in_correct_context(self):
        """
        The menu link was rendered as a relative link, which means it generally
        wasn't on the correct context.  e.g. /news/@@cmsui-menu is the folder,
        not the default view.
        """

        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document_id = portal.invokeFactory("Document", "menu_test_context", title="Context test")
        document = portal[document_id]
        # Commit so the change in roles is visible to the browser
        transaction.commit()
        
        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        self.assertIn("menu_test_context", browser.url)
    def test_panel_linked_to_in_menu(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "panel_linked_to_in_menu_doc",
                                delete_first=True,
                                title="Workflow transitions")
        # Commit so the change in roles is visible to the browser
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()

        # raises exception if not present
        browser.getLink("Public draft").click()
        self.assertIn("form.widgets.workflow_action", browser.contents)
Ejemplo n.º 20
0
 def test_can_enter_changenote(self):
     browser = Browser(self.layer['app'])
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
     document = createObject(portal, "Document", "changenote_transition_doc", delete_first=True, title="Workflow note")
     transaction.commit()
     
     browser_login(portal, browser)
     browser.open(document.absolute_url())
     browser.getLink("Manage page").click()
     browser.getLink("Public draft").click()
     workflow_actions = browser.getControl(name="form.widgets.workflow_action:list")
     workflow_actions.getControl(value="publish").click()
     # We set up a comment this time
     browser.getControl(name="form.widgets.comment").value = "wibble fkjwel"
     browser.getControl("Save").click()
     
     # and it shows up in the workflow history
     self.assertEqual("publish", document.workflow_history['plone_workflow'][-1]['action'])
     self.assertEqual("wibble fkjwel", document.workflow_history['plone_workflow'][-1]['comments'])
    def test_can_enter_expiration_date_without_transaction(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "expiration_date_without_transition_doc",
                                delete_first=True,
                                title="Workflow note")
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        browser.getLink("Public draft").click()

        # Don't select any workflow action, but set date
        next_year = datetime.now() + timedelta(365)
        next_year = next_year - timedelta(seconds=next_year.second,
                                          microseconds=next_year.microsecond)
        browser.getControl(
            name="form.widgets.expiration_date-day").value = str(next_year.day)
        browser.getControl(name="form.widgets.expiration_date-month").value = [
            str(next_year.month)
        ]
        browser.getControl(
            name="form.widgets.expiration_date-year").value = str(
                next_year.year)
        browser.getControl(
            name="form.widgets.expiration_date-hour").value = str(
                next_year.hour)
        browser.getControl(
            name="form.widgets.expiration_date-min").value = str(
                next_year.minute)
        browser.getControl("Save").click()

        # Still draft, but expiration date set
        self.assertEqual(
            "visible",
            portal.portal_workflow.getInfoFor(document, "review_state"))
        self.assertEqual(DateTime(next_year), document.getRawExpirationDate())
Ejemplo n.º 22
0
    def test_menu_sublinks_rendered_in_correct_context(self):
        """
        The menu link was rendered as a relative link, which means it generally
        wasn't on the correct context.  e.g. /news/@@cmsui-menu is the folder,
        not the default view.
        """

        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document_id = portal.invokeFactory("Document",
                                           "menu_test_context",
                                           title="Context test")
        document = portal[document_id]
        # Commit so the change in roles is visible to the browser
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        self.assertIn("menu_test_context", browser.url)
    def test_available_workflow_transition_shown_in_workflow_panel(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "transition_shown_in_workflow_panel_doc",
                                delete_first=True,
                                title="Workflow transitions")
        # Commit so the change in roles is visible to the browser
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        browser.getLink("Public draft").click()

        # The submit button should be available
        transitions = portal.portal_workflow.getTransitionsFor(document)
        transition_ids = [transition['id'] for transition in transitions]
        # Ensure the workflow transition we are going to look for in the
        # workflow panel is actually available to save debugging headaches
        # later
        self.assertEqual(sorted(['submit', 'hide', 'publish']),
                         sorted(transition_ids))

        # Make sure we have both labels and values for all possible workflow actions
        workflow_actions = browser.getControl(
            name="form.widgets.workflow_action:list")
        self.assertEqual(len(workflow_actions.mech_control.items), 3)
        self.assertEqual(
            workflow_actions.getControl(
                label='Submit for publication').optionValue, 'submit')
        self.assertEqual(
            workflow_actions.getControl(label='Make private').optionValue,
            'hide')
        self.assertEqual(
            workflow_actions.getControl(label='Publish').optionValue,
            'publish')
    def test_choosing_transition_transitions_content(self):
        browser = Browser(self.layer['app'])
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Member', 'Manager'))
        document = createObject(portal,
                                "Document",
                                "do_workflow_transition_doc",
                                delete_first=True,
                                title="Workflow transitioning")
        transaction.commit()

        browser_login(portal, browser)
        browser.open(document.absolute_url())
        browser.getLink("Manage page").click()
        browser.getLink("Public draft").click()
        workflow_actions = browser.getControl(
            name="form.widgets.workflow_action:list")
        workflow_actions.getControl(value="publish").click()
        browser.getControl("Save").click()

        self.assertEqual(
            "published",
            portal.portal_workflow.getInfoFor(document, "review_state"))
Ejemplo n.º 25
0
 def test_delete_existence(self): 
     setRoles(self.layer['portal'], TEST_USER_ID, ['Owner'])
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/key-party/he/@@cmsui-menu')
     self.assertTrue(browser.getLink('Delete').url.endswith('he/delete_confirmation'))
Ejemplo n.º 26
0
 def test_visible_to_members(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/cmsui-menu')
     self.assertTrue('Logged in as test_user_1_')
Ejemplo n.º 27
0
 def test_visible_to_members(self):
     browser = Browser(self.layer['app'])
     browser_login(self.portal, browser)
     browser.open('http://nohost/plone/cmsui-menu')
     self.assertTrue('Logged in as test_user_1_')
Ejemplo n.º 28
0
 def test_bbb_view(self):
     browser_login(self.portal, self.browser)
     self.browser.open('http://nohost/plone/@@folder_contents')
     self.assertTrue('cmsui-structure' in self.browser.contents)
Ejemplo n.º 29
0
 def test_bbb_view(self):
     browser_login(self.portal, self.browser)
     self.browser.open('http://nohost/plone/@@folder_contents')
     self.assertTrue('cmsui-structure' in self.browser.contents)