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