Example #1
0
    def test_destruction_confirmation_on_import(self, browser):
        self.use_spec('foo')
        specdetails.visit('Destructive Workflow (destructive-workflow)')
        specdetails.button_write_and_import().click()
        statusmessages.assert_message(
            'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo')

        self.use_spec('bar')
        specdetails.visit('Destructive Workflow (destructive-workflow)')
        specdetails.button_write_and_import().click()

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

        # confirmation dialog displayed
        self.assertEquals(
            'Importing this workflow renames or removes states.'
            ' Changing states can reset the workflow status of affected'
            ' objects to the initial state.',
            browser.css('.confirmation-message').first.text,
        )

        # No changes on cancel
        browser.find('I am on production').click()
        self.assert_current_states('Foo')

        specdetails.button_write_and_import().click()
        browser.find('I know what I am doing').click()
        statusmessages.assert_message(
            'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo', 'Bar')
Example #2
0
    def test_destruction_confirmation_on_import(self, browser):
        self.use_spec('foo')
        specdetails.visit('Destructive Workflow (destructive-workflow)')
        specdetails.button_write_and_import().click()
        statusmessages.assert_message(
            'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo')

        self.use_spec('bar')
        specdetails.visit('Destructive Workflow (destructive-workflow)')
        specdetails.button_write_and_import().click()

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

        # confirmation dialog displayed
        self.assertEquals(
            'Importing this workflow renames or removes states.'
            ' Changing states can reset the workflow status of affected'
            ' objects to the initial state.',
            browser.css('.confirmation-message').first.text,)

        # No changes on cancel
        browser.find('I am on production').click()
        self.assert_current_states('Foo')

        specdetails.button_write_and_import().click()
        browser.find('I know what I am doing').click()
        statusmessages.assert_message(
            'Workflow destructive-workflow successfully imported.')
        self.assert_current_states('Foo', 'Bar')
Example #3
0
    def test_definitionXML_not_touched_on_error(self, browser):
        with open(INVALID_WORKFLOW_DEFINITION_XML, 'w+') as file_:
            file_.write('some contents')

        specdetails.visit('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([], statusmessages.info_messages(),
                          'Expecting no "info" portal messages.')

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

        remove_definition_xml(INVALID_WORKFLOW_DEFINITION_XML)
Example #4
0
    def test_definitionXML_not_touched_on_error(self, browser):
        with open(INVALID_WORKFLOW_DEFINITION_XML, 'w+') as file_:
            file_.write('some contents')

        specdetails.visit('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([], statusmessages.info_messages(),
                          'Expecting no "info" portal messages.')

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

        remove_definition_xml(INVALID_WORKFLOW_DEFINITION_XML)
Example #5
0
    def test_write_workflow_XML(self, browser):
        self.assertFalse(os.path.exists(BAR_DEFINITION_XML),
                         'Expected %s to not exist yet.' % BAR_DEFINITION_XML)

        specdetails.visit('Bar Workflow (wf-bar)')
        specdetails.button_write().click()
        self.assertTrue(os.path.exists(BAR_DEFINITION_XML),
                        'Expected %s to exist now.' % BAR_DEFINITION_XML)
Example #6
0
    def test_write_workflow_XML(self, browser):
        self.assertFalse(os.path.exists(BAR_DEFINITION_XML),
                         'Expected %s to not exist yet.' % BAR_DEFINITION_XML)

        specdetails.visit('Bar Workflow (wf-bar)')
        specdetails.button_write().click()
        self.assertTrue(os.path.exists(BAR_DEFINITION_XML),
                        'Expected %s to exist now.' % BAR_DEFINITION_XML)
Example #7
0
 def test_spec_metadata_table(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertListEqual(
         [['Workflow ID:', 'wf-bar'],
          ['Specification file:',
           '..../profiles/bar/workflows/wf-bar/specification.txt'],
          ['Workflow definition file:',
           '..../profiles/bar/workflows/wf-bar/definition.xml'],
          ['Workflow installed:', 'No'],
          ['Translations location:', '..../locales']],
         specdetails.metadata())
Example #8
0
 def test_spec_metadata_table(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertListEqual(
         [['Workflow ID:', 'wf-bar'],
          [
              'Specification file:',
              '..../profiles/bar/workflows/wf-bar/specification.txt'
          ],
          [
              'Workflow definition file:',
              '..../profiles/bar/workflows/wf-bar/definition.xml'
          ], ['Workflow installed:', 'No'
              ], ['Translations location:', '..../locales']],
         specdetails.metadata())
Example #9
0
    def test_buttons_not_shown(self, browser):
        specdetails.visit('spec-based-workflow')
        # on error, show no buttons
        self.assertFalse(
            specdetails.button_write(),
            'The Button "Write workflow definition" should not be visible')

        self.assertFalse(
            specdetails.button_write_and_import(),
            'The Button "Write and Import Workflow" should not be visible')

        self.assertFalse(
            specdetails.button_reindex(),
            'The Button "Update security settings" should not be visible')
Example #10
0
    def test_buttons_not_shown(self, browser):
        specdetails.visit('spec-based-workflow')
        # on error, show no buttons
        self.assertFalse(
            specdetails.button_write(),
            'The Button "Write workflow definition" should not be visible')

        self.assertFalse(
            specdetails.button_write_and_import(),
            'The Button "Write and Import Workflow" should not be visible')

        self.assertFalse(
            specdetails.button_reindex(),
            'The Button "Update security settings" should not be visible')
Example #11
0
    def test_translations_po(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        data = specdetails.translations_po()

        self.assertMultiLineEqual(
            '\n'.join((
                    'msgid "Published"',
                    'msgstr "Published"',
                    '',
                    'msgid "wf-bar--ROLE--Editor"',
                    'msgstr "editor"',
                    '',
                    'msgid "wf-bar--ROLE--Manager"',
                    'msgstr "System Administrator"',
                    )),
            data,
            'The default translation content is wrong.')
Example #12
0
    def test_translations_po(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        data = specdetails.translations_po()

        self.assertMultiLineEqual(
            '\n'.join((
                'msgid "Published"',
                'msgstr "Published"',
                '',
                'msgid "wf-bar--ROLE--Editor"',
                'msgstr "editor"',
                '',
                'msgid "wf-bar--ROLE--Manager"',
                'msgstr "System Administrator"',
                '',
                'msgid "wf-bar--STATUS--published"',
                'msgstr "Published"',
            )), data, 'The default translation content is wrong.')
    def test_translations_pot(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        data = specdetails.translations_pot()

        self.assertMultiLineEqual(
            '\n'.join((
                    'msgid "Published"',
                    'msgstr ""',
                    '',
                    'msgid "wf-bar--ROLE--Editor"',
                    'msgstr ""',
                    '',
                    'msgid "wf-bar--ROLE--Manager"',
                    'msgstr ""',
                    '',
                    'msgid "wf-bar--STATUS--published"',
                    'msgstr ""',
                    )),
            data,
            'The translation template content is wrong.')
Example #14
0
    def test_action_groups(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        mapping = specdetails.action_groups()
        self.assertIn('view (view)', mapping, 'No action group "view" found.')

        self.assertIn('edit (edit)', mapping, 'No action group "edit" found.')

        self.assertIn(
            'Access contents information', mapping['view (view)'],
            'Permission "Access contents information" not in action'
            ' group "view"?')

        self.assertNotIn(
            'Modify portal content', mapping['view (view)'],
            'Permission "Modify portal content" should not be in action'
            ' group "view".')

        self.assertIn(
            'Modify portal content', mapping['edit (edit)'],
            'Permission "Modify portal content" not in action'
            ' group "edit"?')
Example #15
0
    def test_write_and_import(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        specdetails.button_write_and_import().click()

        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?')

        statusmessages.assert_message('Workflow wf-bar successfully imported.')
Example #16
0
    def test_action_groups(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        mapping = specdetails.action_groups()
        self.assertIn('view (view)', mapping,
                      'No action group "view" found.')

        self.assertIn('edit (edit)', mapping,
                      'No action group "edit" found.')

        self.assertIn(
            'Access contents information', mapping['view (view)'],
            'Permission "Access contents information" not in action'
            ' group "view"?')

        self.assertNotIn(
            'Modify portal content', mapping['view (view)'],
            'Permission "Modify portal content" should not be in action'
            ' group "view".')

        self.assertIn(
            'Modify portal content', mapping['edit (edit)'],
            'Permission "Modify portal content" not in action'
            ' group "edit"?')
Example #17
0
    def test_write_and_import(self, browser):
        specdetails.visit('Bar Workflow (wf-bar)')
        specdetails.button_write_and_import().click()

        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?')

        statusmessages.assert_message('Workflow wf-bar successfully imported.')
Example #18
0
 def test_update_security(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     specdetails.button_reindex().click()
     statusmessages.assert_message('Security update: 0 objects updated.')
Example #19
0
 def test_details_view_heading(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertEquals('Bar Workflow', plone.first_heading())
Example #20
0
 def test_heading_shows_wfid(self, browser):
     specdetails.visit('spec-based-workflow')
     self.assertEquals('spec-based-workflow', plone.first_heading(),
                       'Workflow title is wrong.')
Example #21
0
 def test_update_translations(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     specdetails.button_update_locales().click()
     statusmessages.assert_message(
         'wf-bar: The translations were updated in your locales directory.'
         ' You should now run bin/i18n-build')
Example #22
0
 def test_unmanaged_permissions(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertIn('Plone Site Setup: Calendar',
                   specdetails.ignored_permissions())
     self.assertIn('Private, only accessible from trusted code',
                   specdetails.unknown_permissions())
Example #23
0
 def test_error_messages_shown(self, browser):
     specdetails.visit('spec-based-workflow')
     statusmessages.assert_message(
         'The specification file could not be parsed:'
         ' Exactly one ini-style section is required,'
         ' containing the workflow title.')
Example #24
0
 def test_update_security(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     specdetails.button_reindex().click()
     statusmessages.assert_message('Security update: 0 objects updated.')
Example #25
0
 def test_update_translations(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     specdetails.button_update_locales().click()
     statusmessages.assert_message(
         'wf-bar: The translations were updated in your locales directory.'
         ' You should now run bin/i18n-build')
Example #26
0
 def test_details_view_heading(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertEquals('Bar Workflow', plone.first_heading())
Example #27
0
 def test_error_messages_shown(self, browser):
     specdetails.visit('spec-based-workflow')
     statusmessages.assert_message(
         'The specification file could not be parsed:'
         ' Exactly one ini-style section is required,'
         ' containing the workflow title.')
Example #28
0
 def test_specification_text(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertIn(
         'Status Published:', specdetails.specification_text(),
         'Seems the specification file is not printed in the view.')
Example #29
0
 def test_unmanaged_permissions(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     unmanaged = specdetails.unmanaged_permissions()
     self.assertIn(
         'Plone Site Setup: Calendar', unmanaged,
         'Expected permission to be unmanaged.')
Example #30
0
 def test_german_action_groups(self, browser):
     self.switch_language('de')
     specdetails.visit('Bar Workflow (wf-bar)')
     mapping = specdetails.action_groups()
     self.assertIn('ansehen (view)', mapping.keys(),
                   'No action group "ansehen" found.')
Example #31
0
 def test_specification_text(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertIn(
         'Status Published:',
         specdetails.specification_text(),
         'Seems the specification file is not printed in the view.')
Example #32
0
 def test_heading_shows_wfid(self, browser):
     specdetails.visit('spec-based-workflow')
     self.assertEquals('spec-based-workflow',
                       plone.first_heading(),
                       'Workflow title is wrong.')
Example #33
0
 def test_german_action_groups(self, browser):
     self.switch_language('de')
     specdetails.visit('Bar Workflow (wf-bar)')
     mapping = specdetails.action_groups()
     self.assertIn('ansehen (view)', mapping.keys(),
                   'No action group "ansehen" found.')
 def test_unmanaged_permissions(self, browser):
     specdetails.visit('Bar Workflow (wf-bar)')
     self.assertIn(
         'Plone Site Setup: Calendar', specdetails.ignored_permissions())
     self.assertIn(
         'Private, only accessible from trusted code', specdetails.unknown_permissions())