def test_document_of_submitted_proposal_cannot_be_edited(self, browser): repo, repo_folder = create(Builder('repository_tree')) dossier = create(Builder('dossier').within(repo_folder)) committee = create(Builder('committee')) proposal = create(Builder('proposal') .within(dossier) .with_proposal_file('Fake proposal file body') .having(title='Mach doch', committee=committee.load_model())) browser.login().open(proposal.get_proposal_document(), view='edit') self.assertEquals('Edit Document', plone.first_heading(), 'Document should be editable.') browser.login().open(proposal, view='tabbedview_view-overview') browser.css('#pending-submitted').first.click() self.assertEqual(['Proposal successfully submitted.'], info_messages()) with browser.expect_unauthorized(): browser.open(proposal.get_proposal_document(), view='edit') submitted_proposal = proposal.load_model().resolve_submitted_proposal() browser.open(submitted_proposal, view='tabbedview_view-overview') browser.find('Reject').click() browser.fill({'Comment': u'Bitte \xfcberarbeiten'}).submit() browser.login().open(proposal.get_proposal_document(), view='edit') self.assertEquals('Edit Document', plone.first_heading(), 'Document should be editable again.')
def test_title_of_news_listing(self, browser): page = create(Builder('content page').titled('Contentpage')) newsfolder = create(Builder('news folder').within(page).titled('News')) browser.login().visit(page, view='@@newslisting') self.assertEquals('Contentpage - News', plone.first_heading()) browser.visit(newsfolder) self.assertEquals('News', plone.first_heading())
def test_archival_file_management_view_only_visible_for_managers( self, browser): self.login(self.regular_user, browser) with browser.expect_unauthorized(): browser.open(self.expired_dossier, view="archival_file_management") self.assertEqual('Insufficient Privileges', plone.first_heading()) self.login(self.manager, browser) browser.open(self.expired_dossier, view="archival_file_management") self.assertEqual(self.expired_dossier.Title().decode("utf-8"), plone.first_heading())
def test_fill_umlauts(self, browser): self.grant('Manager') browser.login().open() factoriesmenu.add('Page') browser.fill({'Title': u'F\xf6lder'}).save() statusmessages.assert_no_error_messages() self.assertEquals(u'F\xf6lder', plone.first_heading())
def test_fill_field_with_utf8_umlauts(self, browser): browser.login(SITE_OWNER_NAME).open() factoriesmenu.add('Folder') browser.fill({'Title': u'F\xf6lder'.encode('utf-8'), 'Summary': u'The f\xf6lder description'.encode('utf-8')}).save() self.assertEquals('listing_view', plone.view()) self.assertEquals(u'F\xf6lder', plone.first_heading())
def test_fill_archtypes_field_with_unicode_umlauts(self, browser): browser.login(SITE_OWNER_NAME).open() factoriesmenu.add('Folder') browser.fill({'Title': u'F\xf6lder', 'Description': u'The f\xf6lder description'}).submit() self.assertEquals('folder_listing', plone.view()) self.assertEquals(u'F\xf6lder', plone.first_heading())
def test_unauthorized_when_came_from_does_not_exist(self, browser): # When the came_from URL does not exist, we want the regular unauthorized # page to appear when logged in. url = ('{0}/acl_users/credentials_cookie_auth/require_login' '?came_from={0}/does/not/exist').format(self.portal.absolute_url()) with browser.expect_unauthorized(): browser.login().open(url) self.assertEquals('Insufficient Privileges', plone.first_heading())
def test_unauthorized_when_came_from_does_not_exist(self, browser): # When the came_from URL does not exist, we want the regular unauthorized # page to appear when logged in. url = ('{0}/acl_users/credentials_cookie_auth/require_login' '?came_from={0}/does/not/exist').format( self.portal.absolute_url()) browser.login().open(url) self.assertEquals('Insufficient Privileges', plone.first_heading())
def test_can_be_added_as_manager(self, browser): self.login(self.manager, browser) browser.open(view='folder_contents') factoriesmenu.add('WorkspaceRoot') browser.fill({'Title (German)': u'Teamr\xe4ume', 'Title (French)': u'Ateliers'}).save() statusmessages.assert_no_error_messages() self.assertEquals(u'Teamr\xe4ume', plone.first_heading())
def test_add_page(self, browser): # Page browser.login().visit() factoriesmenu.add('ContentPage') browser.fill({'Title': u'A test page'}) browser.find_button_by_label('Save').click() self.assertEquals('A test page', plone.first_heading())
def test_first_heading_of_news_listing_on_contentpage(self, browser): """ This test makes sure that the first heading is correct when the view "@@news_listing" is called on a content page. "News" will be appended to the title of the content page. """ page = create(Builder('sl content page') .titled(u'Content page')) browser.login().visit(page, view='@@news_listing') self.assertEquals(u'Content page - News', plone.first_heading())
def test_first_heading_of_news_listing_on_news_folder(self, browser): """ This test makes sure that the first heading is correct when the view "@@news_listing" is called on a news folder. """ news_folder = create(Builder(u'news folder') .titled(u'A News Folder') .with_property('layout', 'news_listing')) browser.visit(news_folder) self.assertEquals(u'A News Folder', plone.first_heading())
def test_edit_meeting_reports_write_conflicts(self, tab1): self.login(self.committee_responsible, tab1) with tab1.clone() as tab2: with freeze(utcnow_tz_aware()) as clock: tab1.open(self.meeting, view='edit-meeting') tab2.open(self.meeting, view='edit-meeting') tab1.fill({'Title': u'Title by tab 1'}).save() statusmessages.assert_message('Changes saved', browser=tab1) self.assertEquals(u'Title by tab 1', plone.first_heading(browser=tab1)) create_session().flush() clock.forward(minutes=1) tab2.fill({'Title': u'Title by tab 2'}).save() statusmessages.assert_message( 'Your changes were not saved,' ' the protocol has been modified in the meantime.', browser=tab2) tab2.open(self.meeting) self.assertEquals(u'Title by tab 1', plone.first_heading(browser=tab2))
def test_edit_meeting_metadata(self, browser): self.maxDiff = None self.login(self.committee_responsible, browser) browser.open(self.meeting) self.assertEquals(u'9. Sitzung der Rechnungspr\xfcfungskommission', plone.first_heading()) self.assertEquals( { 'State:': 'Pending', 'Start:': 'Sep 12, 2016 05:30 PM', 'End:': 'Sep 12, 2016 07:00 PM', 'Presidency:': u'Sch\xf6ller Heidrun', 'Secretary:': u'M\xfcller Henning', 'Location:': u'B\xfcren an der Aare', 'Meeting dossier:': 'Sitzungsdossier 9/2017' }, byline.text_dict()) editbar.contentview('Edit').click() browser.fill({ 'Title': u'New Meeting Title', 'Other Participants': 'Staatsanwalt', 'Protocol start-page': '27', 'Location': 'Sitzungszimmer 3', 'Start': '13.10.2016 08:00', 'End': '13.10.2016 10:00' }).save() statusmessages.assert_message('Changes saved') self.assertEquals('New Meeting Title', plone.first_heading()) self.assertEquals( { 'State:': 'Pending', 'Start:': 'Oct 13, 2016 08:00 AM', 'End:': 'Oct 13, 2016 10:00 AM', 'Presidency:': u'Sch\xf6ller Heidrun', 'Secretary:': u'M\xfcller Henning', 'Location:': u'Sitzungszimmer 3', 'Meeting dossier:': 'New Meeting Title' }, byline.text_dict()) self.assertEquals('New Meeting Title', self.meeting_dossier.title)
def assert_root_access(self, expect_has_access, browser=default_browser): root_id = 'workspaces' browser.open() if expect_has_access: self.assertIn(root_id, globalnav.portaltabs().text) browser.open(self.workspace_root) self.assertEquals(u'Teamr\xe4ume', plone.first_heading()) else: self.assertNotIn(root_id, globalnav.portaltabs().text) with self.assertRaises(Unauthorized): self.workspace_root
def test_first_heading_of_news_listing_on_news_listing_block_within_root(self, browser): """ This test makes sure that the first heading is correct when the view "@@news_listing" is called on a news listing block which has been added on the subsite view of the Plone site (root). """ block = create(Builder('news listing block') .titled(u'Awesome News')) browser.login().visit(block, view='@@news_listing') self.assertEquals(u'Awesome News', plone.first_heading())
def test_add_noticecategory(self, browser): noticeboard = create(Builder('noticeboard').titled(u'Noticeboard')) browser.login().visit(noticeboard) factoriesmenu.add('NoticeCategory') browser.fill({ 'Title': u'This is a Category', 'Terms and Conditions': 'Anything' }) browser.find_button_by_label('Save').click() self.assertEquals(u'This is a Category', plone.first_heading())
def test_viewlet_should_not_break(self, browser): # When the package is not installed, the viewlet should # not break anything. browser.open() self.assertEquals('Plone site', plone.first_heading()) self.assertNotIn( 'error', browser.css('#portal-top').first.text, 'The viewlet should not be rendered, but it seems' ' to have been rendered with an error.')
def test_document_of_rejected_proposal_can_be_edited(self, browser): self.login(self.committee_responsible, browser) browser.open(self.submitted_word_proposal, view='tabbedview_view-overview') browser.find('Reject').click() browser.fill({'Comment': u'Bitte \xfcberarbeiten'}).submit() self.login(self.dossier_responsible, browser) document = self.word_proposal.get_proposal_document() browser.open(self.word_proposal.get_proposal_document(), view='edit') browser.open(document, view='edit') self.assertEquals('Edit Document', plone.first_heading(), 'Document should be editable.')
def test_add_notice(self, browser): board, category = self._create_content() browser.login().visit(category) factoriesmenu.add('Notice') browser.fill({ 'Title': u'This is a Notice', 'Price': '100', 'Terms and Conditions': True, 'E-Mail': u'*****@*****.**', 'Text': u'Anything', }) browser.find_button_by_label('Save').click() self.assertEquals(u'This is a Notice', plone.first_heading())
def test_nested_contentpages(self, browser): nested = create(Builder('sl content page') .titled(u'Nested') .within(self.page)) browser.login().visit(self.page) self.assertFalse(browser.css('.sl-block'), 'Expect no block, also the contentpage should not be ' 'visible as block') browser.visit(nested) self.assertEquals('Nested', plone.first_heading())
def test_edit_meeting_metadata(self, browser): self.maxDiff = None self.login(self.committee_responsible, browser) browser.open(self.meeting) self.assertEquals(u'9. Sitzung der Rechnungspr\xfcfungskommission', plone.first_heading()) self.assertEquals( {'State:': 'Pending', 'Start:': 'Sep 12, 2016 05:30 PM', 'End:': 'Sep 12, 2016 07:00 PM', 'Presidency:': u'Sch\xf6ller Heidrun', 'Secretary:': u'Secretary C\xf6mmittee', 'Location:': u'B\xfcren an der Aare', 'Meeting dossier:': 'Sitzungsdossier 9/2017'}, byline.text_dict()) editbar.contentview('Edit').click() browser.fill({'Title': u'New Meeting Title', 'Other Participants': 'Staatsanwalt', 'Protocol start-page': '27', 'Location': 'Sitzungszimmer 3', 'Start': '13.10.2016 08:00', 'End': '13.10.2016 10:00'}).save() statusmessages.assert_message('Changes saved') self.assertEquals('New Meeting Title', plone.first_heading()) self.assertEquals( {'State:': 'Pending', 'Start:': 'Oct 13, 2016 08:00 AM', 'End:': 'Oct 13, 2016 10:00 AM', 'Presidency:': u'Sch\xf6ller Heidrun', 'Secretary:': u'Secretary C\xf6mmittee', 'Location:': u'Sitzungszimmer 3', 'Meeting dossier:': 'New Meeting Title'}, byline.text_dict()) self.assertEquals('New Meeting Title', self.meeting_dossier.title)
def test_user_can_only_add_and_edit_notices(self, browser): user = create(Builder('user')) browser.login(user).visit() with self.assertRaises(ValueError): # ValueError: Cannot add "NoticeBoard": no factories menu visible factoriesmenu.add('NoticeBoard') noticeboard = create(Builder('noticeboard')) browser.visit(noticeboard) with self.assertRaises(ValueError): # ValueError: Cannot add "NoticeBoard": no factories menu visible factoriesmenu.add('NoticeCategory') category = create(Builder('noticecategory').within(noticeboard)) browser.visit(category) browser.css('a.add-link').first.click() # factoriesmenu.add('Notice') browser.fill( { 'Title': u'This is a Notice', 'Price': '100', 'Terms and Conditions': True, 'E-Mail': u'*****@*****.**', 'Text': u'Anything', } ) browser.find_button_by_label('Save').click() self.assertEquals(u'This is a Notice', plone.first_heading()) browser.visit('@@edit') browser.fill( { 'Title': u'Changed', } ) browser.find_button_by_label('Save').click() self.assertEquals(u'Changed', plone.first_heading())
def test_empy_trash(self, browser): self.grant('Site Administrator') Trasher(create(Builder('folder').titled(u'Foo'))).trash() self.assertIn('foo', self.portal.objectIds()) transaction.commit() browser.login().open().click_on('Trash') self.assertEquals('Trash', plone.first_heading()) browser.click_on('Clean trash') self.assertEquals( 'Are you sure you want to permanently delete all objects in the trash?', plone.first_heading()) self.assertIn('foo', self.portal.objectIds()) browser.click_on('Cancel') self.assertEquals('Trash', plone.first_heading()) self.assertIn('foo', self.portal.objectIds()) browser.click_on('Clean trash').click_on('Delete') self.assertEquals('Trash', plone.first_heading()) self.assertNotIn('foo', self.portal.objectIds())
def test_terms_and_conditions_need_to_be_accepted(self, browser): board, category = self._create_content() browser.login().visit(category) factoriesmenu.add('Notice') browser.fill({ 'Title': u'This is a Notice', 'E-Mail': u'*****@*****.**', 'Price': '100', 'Text': u'Anything', }) browser.find_button_by_label('Save').click() self.assertEquals(u'Add Notice', plone.first_heading()) statusmessages.assert_message('There were some errors.') self.assertEqual(u'You need to accept the terms and conditions', browser.css('.fieldErrorBox > .error').first.text)
def test_list_images(self, browser): notice = self._create_content() for number in range(4): create(Builder('noticeimage').within(notice).with_dummy_content()) browser.login().visit(notice) self.assertEqual( 4, len(browser.css('.notice-image-slider img')), 'Expect 4 images' ) self.assertEquals(u'This is a N\xf6tice', plone.first_heading()) self.assertEquals(u'S\xf6mething', browser.css('.notice-text').first.text)
def test_content_is_deleted_when_trash_not_installed(self, browser): catalog = getToolByName(self.layer['portal'], 'portal_catalog') self.grant('Contributor') folder = create(Builder('folder').within(create(Builder('folder')))) self.assertIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(2, len(catalog.unrestrictedSearchResults())) browser.login().visit(folder) browser.click_on('Delete') self.assertEquals( 'Do you really want to delete this folder and all its contents?', plone.first_heading()) browser.click_on('Delete') self.assertNotIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(1, len(catalog.unrestrictedSearchResults()))
def test_portlet_edit_view(self, browser): self.create_blog_entries() browser.login() self.add_portlet(browser, **{'Title': 'Portlet title'}) browser.find_link_by_text('BlogEntries collection portlet').click() self.assertEquals( plone.first_heading(), 'Edit BlogEntry collection portlet', 'Wrong title, perhaps we are not on the portlet ' 'edit view') browser.fill({'Title': 'New Title'}) browser.find('Save').click() browser.visit() self.assertEquals( browser.css( '.portlet.blogentryCollection .portletHeader').first.text, 'New Title', 'Changing the portlet title did not work.')
def test_children_of_site_root_are_trashed_instead_of_deleted( self, browser): catalog = getToolByName(self.layer['portal'], 'portal_catalog') self.grant('Contributor') folder = create(Builder('folder')) self.assertIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(1, len(catalog.unrestrictedSearchResults())) self.assert_provides(folder, None) browser.login().visit(folder) browser.click_on('Delete') self.assertEquals( 'Do you really want to delete this folder and all its contents?', plone.first_heading()) browser.click_on('Delete') self.assertIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(1, len(catalog.unrestrictedSearchResults())) self.assert_provides(folder, IRestorable, ITrashed)
def test_empty_trash_when_parent_and_child_are_both_trashed(self, browser): """Regression test: when trying to delete a child but the parent was deleted bevore, an exception is raised. Solution: do not delete children and parents in the same set; just delete parents, which is recursive anyway. """ self.grant('Site Administrator') parent = create(Builder('folder').titled(u'Parent')) child = create(Builder('folder').titled(u'Child').within(parent)) Trasher(child).trash() Trasher(parent).trash() transaction.commit() browser.login().open().click_on('Trash') self.assertEquals('Trash', plone.first_heading()) self.assertIn('parent', self.portal.objectIds()) browser.click_on('Clean trash').click_on('Delete') self.assertNotIn('parent', self.portal.objectIds())
def test_deleted_content_is_marked_with_IRestorable(self, browser): catalog = getToolByName(self.layer['portal'], 'portal_catalog') self.grant('Contributor') folder = create(Builder('folder').within(create(Builder('folder')))) subfolder = create(Builder('folder').within(folder)) self.assertIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(3, len(catalog.unrestrictedSearchResults())) self.assert_provides(folder, None) self.assert_provides(subfolder, None) browser.login().visit(folder) browser.click_on('Delete') self.assertEquals( 'Do you really want to delete this folder and all its contents?' ' (This will delete a total of 2 items.)', plone.first_heading()) self.assert_provides(folder, None) self.assert_provides(subfolder, None) browser.click_on('Delete') self.assertIn(folder.getId(), aq_parent(aq_inner(folder)).objectIds()) self.assertEqual(3, len(catalog.unrestrictedSearchResults())) self.assert_provides(folder, IRestorable, ITrashed) self.assert_provides(subfolder, ITrashed)
def test_repository_root_view_renders(self, browser): self.login(self.regular_user, browser=browser) browser.open(self.repository_root) self.assertEquals('Ordnungssystem', plone.first_heading())
def test_slider_container_is_addable(self, browser): browser.login().open() factoriesmenu.add('Slider Container') browser.fill({'Title': 'Container 1'}).submit() self.assertEquals('Container 1', plone.first_heading()) self.assertEquals('ftw-slider-container', plone.portal_type())
def test_heading_is_subject(self, browser): mail = create(Builder('mail').with_message(mail_asset('latin1'))) browser.login().visit(mail) self.assertEquals(u'Die B\xfcrgschaft', plone.first_heading())
def test_unauthorized_visible_when_raised_in_publishing(self, browser): self.login(self.regular_user, browser=browser) with browser.expect_unauthorized(): browser.open(view='test-publishing-unauthorized') self.assertEquals('Insufficient Privileges', plone.first_heading())
def test_fill_field(self, browser): browser.login(SITE_OWNER_NAME).open() factoriesmenu.add('Folder') browser.fill({'Title': 'The Folder'}).save() self.assertEquals('listing_view', plone.view()) self.assertEquals('The Folder', plone.first_heading())
def test_unauthorized_visible_when_raised_in_publishing(self, browser): browser.login().open(view='test-publishing-unauthorized') self.assertEquals('Insufficient Privileges', plone.first_heading())
def test_add_noticeboard(self, browser): browser.login().visit() factoriesmenu.add('NoticeBoard') browser.fill({'Title': u'This is our NoticeBoard'}) browser.find_button_by_label('Save').click() self.assertEquals(u'This is our NoticeBoard', plone.first_heading())
def test_first_heading_on_at_addform(self, browser): browser.login(SITE_OWNER_NAME).open() factoriesmenu.add('Folder') self.assertEquals('Add Folder', plone.first_heading())
def test_preparing_changes_do_not_trigger_csrf_protection(self, browser): self.login(self.administrator, browser) self.repository_root.title_de = 'New Repository Root Title' browser.open(self.repository_root) self.assertEquals('New Repository Root Title', plone.first_heading())
def test_add_page(self, browser): browser.login().visit() factoriesmenu.add("ContentPage") browser.fill({"Title": u"This is a ContentPage"}) browser.find_button_by_label("Save").click() self.assertEquals(u"This is a ContentPage", plone.first_heading())
def test_heading_shows_wfid(self, browser): specdetails.visit('spec-based-workflow') self.assertEquals('spec-based-workflow', plone.first_heading(), 'Workflow title is wrong.')
def test_fill_umlauts(self, browser): browser.login(SITE_OWNER_NAME).open() factoriesmenu.add("Page") browser.fill({"Title": u"F\xf6lder"}).save() statusmessages.assert_no_error_messages() self.assertEquals(u"F\xf6lder", plone.first_heading())
def test_details_view_heading(self, browser): specdetails.visit('Bar Workflow (wf-bar)') self.assertEquals('Bar Workflow', plone.first_heading())
def test_document_of_draft_proposal_can_be_edited(self, browser): self.login(self.dossier_responsible, browser) document = self.draft_word_proposal.get_proposal_document() browser.open(document, view='edit') self.assertEquals('Edit Document', plone.first_heading(), 'Document should be editable.')
def test_repository_root_view_renders(self, browser): browser.login(self.administrator).open(self.repository_root) self.assertEquals('Ordnungssystem', plone.first_heading())
def test_first_heading(self, browser): browser.open() self.assertEquals('Plone site', plone.first_heading())
def test_subsite_addable(self, browser): browser.login().visit() factoriesmenu.add('Subsite') browser.fill({'Title': 'This is a Subsite'}).save() self.assertEquals('This is a Subsite', plone.first_heading())