def test_destruction_confirmation_on_import(self):
        self.use_spec('foo')
        SpecDetails().open('Destructive Workflow (destructive-workflow)')
        SpecDetails().button_write_and_import().click()
        Plone().assert_portal_message(
            'info', 'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo')

        self.use_spec('bar')
        SpecDetails().open('Destructive Workflow (destructive-workflow)')
        SpecDetails().button_write_and_import().click()

        # not yet updated
        self.assert_current_states('Foo')

        # confirmation dialog displayed
        self.assertTrue(
            SpecDetailsConfirmation().is_confirmation_dialog_opened(),
            'Expected to be on a confirmation dialog, but was not')

        self.assertEquals(
            'Importing this workflow renames or removes states.'
            ' Changing states can reset the workflow status of affected'
            ' objects to the initial state.',
            SpecDetailsConfirmation().get_confirmation_dialog_text())

        # No changes on cancel
        SpecDetailsConfirmation().cancel()
        self.assert_current_states('Foo')

        SpecDetails().button_write_and_import().click()
        SpecDetailsConfirmation().confirm()
        Plone().assert_portal_message(
            'info', 'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo', 'Bar')
    def test_definitionXML_not_touched_on_error(self):
        with open(INVALID_WORKFLOW_DEFINITION_XML, 'w+') as file_:
            file_.write('some contents')

        SpecDetails().open('Invalid Workflow (invalid-spec)')

        self.assertTrue(
            SpecDetails().button_write_and_import(),
            'The Button "Write and Import Workflow" in "Invalid Workflow"'
            ' should be visible but is not.')
        SpecDetails().button_write_and_import().click()

        self.assertGreater(
            os.path.getsize(INVALID_WORKFLOW_DEFINITION_XML), 0,
            'The definition.xml (%s) is empty, but it should not be touched'
            'since we had an error while generating.' %
            (INVALID_WORKFLOW_DEFINITION_XML))

        self.maxDiff = None
        self.assertEquals([],
                          Plone().portal_text_messages()['info'],
                          'Expecting no "info" portal messages.')

        self.assertEquals([
            'Error while generating the workflow: Action "viewX" is'
            ' neither action group nor transition.'
        ],
                          Plone().portal_text_messages()['error'],
                          'Expecting only the workflow generation error.')

        remove_definition_xml(INVALID_WORKFLOW_DEFINITION_XML)
    def test_write_and_import(self):
        def get_workflow():
            wftool = getToolByName(self.layer['portal'], 'portal_workflow')
            return wftool.get('wf-bar')

        self.assertEquals(
            None, get_workflow(),
            'Expected workflow wf-bar not to be installed, but it was')
        self.assertFalse(
            SpecDetails().is_workflow_installed(),
            'Details view says the workflow is installed, but it is not')

        SpecDetails().button_write_and_import().click()
        self.assertEquals(
            'Bar Workflow',
            get_workflow().title,
            'Workflow title - write / reimport seems not working?')

        Plone().assert_portal_message(
            'info', 'Workflow wf-bar successfully imported.')

        self.assertTrue(
            SpecDetails().is_workflow_installed(),
            'The workflow should be installed, but the details view says it is not'
        )
Beispiel #4
0
 def test_customize_placeholder_by_setting_property(self):
     self.portal._setProperty('search_label', 'Search example.com',
                              'string')
     transaction.commit()
     Plone().visit_portal()
     self.assertEquals('Search example.com',
                       SearchBox().search_field_placeholder)
 def test_default_plone_placeholder_is_used_by_deafult(self):
     Plone().visit_portal()
     default_placeholder = translate('title_search_site',
                                     domain='plone',
                                     context=self.request)
     self.assertEquals(default_placeholder,
                       SearchBox().search_field_placeholder)
    def test_control_panel_entry(self):
        Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
        PloneControlPanel().open()
        self.assertIn('Lawgiver',
                      PloneControlPanel().get_control_panel_links())

        PloneControlPanel().get_control_panel_link('Lawgiver').click()
        self.assertEquals(SpecsListing().listing_url,
                          browser().url, 'Lawgiver control panel link wrong')
Beispiel #7
0
    def test_placeholder_property_can_be_overriden_on_any_context(self):
        self.portal._setProperty('search_label', 'search portal', 'string')
        folder = create(Builder('folder'))
        folder._setProperty('search_label', 'search folder', 'string')
        transaction.commit()

        placeholders = {}

        Plone().login().visit_portal()
        placeholders['portal'] = SearchBox().search_field_placeholder
        Plone().visit(folder)
        placeholders['folder'] = SearchBox().search_field_placeholder

        self.assertEquals(
            {
                'portal': 'search portal',
                'folder': 'search folder'
            }, placeholders)
Beispiel #8
0
    def test_spec_links_are_distinct(self):
        Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
        SpecsListing().open()

        specs = SpecsListing().get_specifications()
        links = map(methodcaller('link_href'), specs)

        self.assertEquals(
            sorted(links), sorted(set(links)),
            'There are ambiguous spec links. Is the hashing wrong?')
    def setUp(self):
        Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)

        # generate the workflow and import it
        SpecDetails().open('Bar Workflow (wf-bar)')
        SpecDetails().button_write().click()
        applyProfile(self.layer['portal'], 'ftw.lawgiver.tests:bar')
        remove_definition_xml()
        transaction.commit()

        SpecDetails().open('Bar Workflow (wf-bar)')
Beispiel #10
0
    def test_listing_spec_order(self):
        Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
        SpecsListing().open()

        specs = SpecsListing().get_specifications()
        self.assertEquals([
            'Bar Workflow (wf-bar)', 'Foo Workflow (wf-foo)',
            'Invalid Workflow (invalid-spec)',
            'My Custom Workflow (my_custom_workflow)',
            'another-spec-based-workflow', 'spec-based-workflow'
        ], map(methodcaller('link_text'),
               specs), 'Workflow specs links in wrong order or wrong amount.')
Beispiel #11
0
    def test_listing_spec_descriptions(self):
        Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
        SpecsListing().open()

        specs = SpecsListing().get_specifications()
        self.assertEquals(
            {'another-spec-based-workflow': '',
             'My Custom Workflow (my_custom_workflow)': \
                 'A three state publication workflow',
             'spec-based-workflow': '',
             'Bar Workflow (wf-bar)': 'Always published',
             'Foo Workflow (wf-foo)': 'Just for testing.',
             'Invalid Workflow (invalid-spec)': 'This workflow cannot be built ' +\
                 'because it has invalid statements.'},

            dict(map(lambda spec: (spec.link_text(), spec.description()),
                     specs)))
    def test_workflow_not_installed(self):
        Plone().assert_portal_message(
            'warning', 'The workflow wf-bar is not installed yet.'
            ' Installing the workflow with the "Write and Import Workflow"'
            ' button does not configure the policy, so no portal type will'
            ' have this workflow.')

        self.assertTrue(
            SpecDetails().button_write(),
            'The Button "Write workflow definition" is not visible?')

        self.assertTrue(
            SpecDetails().button_write_and_import(),
            'The Button "Write and Import Workflow" is not visible?')

        self.assertTrue(
            SpecDetails().button_reindex(),
            'The Button "Update security settings" is not visible?')
    def test_write_and_import(self):
        def get_workflow():
            wftool = getToolByName(self.layer['portal'], 'portal_workflow')
            return wftool.get('wf-bar')

        self.assertEquals('Bar Workflow',
                          get_workflow().title,
                          'Workflow title wrong after initial import.')

        # Change the workflow title in the database
        get_workflow().title = 'Wrong title'
        transaction.commit()

        # reimport with our button
        SpecDetails().button_write_and_import().click()
        self.assertEquals(
            'Bar Workflow',
            get_workflow().title,
            'Workflow title - write / reimport seems not working?')

        Plone().assert_portal_message(
            'info', 'Workflow wf-bar successfully imported.')
Beispiel #14
0
 def test_placeholder_property_is_inherited(self):
     self.portal._setProperty('search_label', 'search site', 'string')
     folder = create(Builder('folder'))
     Plone().login().visit(folder)
     self.assertEquals('search site', SearchBox().search_field_placeholder)
 def setUp(self):
     Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
     SpecDetails().open('Bar Workflow (wf-bar)')
 def test_heading_shows_wfid(self):
     SpecDetails().open('spec-based-workflow')
     self.assertEquals('spec-based-workflow',
                       Plone().get_first_heading(),
                       'Workflow title is wrong.')
Beispiel #17
0
 def test_form_action_is_view_when_solr_enabled(self):
     Plone().login().visit_portal()
     self.assertEquals('http://nohost/plone/@@search',
                       SearchBox().form_action)
Beispiel #18
0
 def test_form_action_is_page_template_when_solr_disabled(self):
     Plone().login().visit_portal()
     self.assertEquals('http://nohost/plone/search',
                       SearchBox().form_action)
 def test_update_security(self):
     SpecDetails().button_reindex().click()
     Plone().assert_portal_message('info',
                                   'Security update: 0 objects updated.')
 def test_details_view_heading(self):
     self.assertEquals('Bar Workflow',
                       Plone().get_first_heading(),
                       'Workflow title is wrong.')
 def setUp(self):
     Plone().login(SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
Beispiel #22
0
 def test_theme_is_rendered_logged_in(self):
     Plone().login().visit_portal()
     self.assertTrue(
         browser().find_by_css('#page-wrapper'),
         'Could not find #page-wrapper - was the theme rendered?')
Beispiel #23
0
 def test_has_solr_cssclass_present_when_solr_enabled(self):
     Plone().login().visit_portal()
     self.assertTrue(SearchBox().has_solr,
                     'The has-solr class is missing on the search <form>')
     self.assertFalse(SearchBox().no_solr,
                      'There is a has-solr AND a no-solr class!?')
 def test_error_messages_shown(self):
     SpecDetails().open('spec-based-workflow')
     Plone().assert_portal_message(
         'error', 'The specification file could not be parsed:'
         ' Exactly one ini-style section is required,'
         ' containing the workflow title.')