def test_status_message_shown_when_local_roles_on_subdossier_are_copied(self, browser):
        assignment_type = ASSIGNMENT_VIA_SHARING
        assignment_class = RoleAssignment.registry[assignment_type]

        self.login(self.administrator, browser=browser)

        browser.open(self.dossier,
                     data=self.make_path_param(self.subdossier), view="copy_items")
        browser.open(self.empty_repofolder)
        browser.click_on('Paste')

        self.assertItemsEqual(info_messages(),
                              ["Objects from clipboard successfully pasted."])

        manager = RoleAssignmentManager(self.subsubdossier)
        manager.add_or_update_assignment(
            assignment_class(self.regular_user.id,
                             ['Reader', 'Editor', 'Contributor']))
        manager = RoleAssignmentManager(self.subsubdossier)
        assignments = manager.get_assignments_by_cause(assignment_type)
        self.assertEqual(1, len(assignments))

        browser.open(self.dossier,
                     data=self.make_path_param(self.subdossier), view="copy_items")
        browser.open(self.empty_repofolder)
        browser.click_on('Paste')

        self.assertItemsEqual(info_messages(),
                              ["Some local roles were copied with the objects",
                               "Objects from clipboard successfully pasted."])
示例#2
0
    def test_unlock_button_available_only_for_managers(self, browser):
        with freeze():
            self.login(self.regular_user, browser)
            with freeze(FREEZE_DATE):
                oc_url = self.fetch_document_checkout_oc_url(
                    browser, self.document)

            expected_token = {
                u'action': u'checkout',
                u'documents': [u'createtreatydossiers000000000002'],
                u'exp': 4121033100,
                u'sub': u'kathi.barfuss',
                u'url': u'http://nohost/plone/oc_checkout',
            }
            raw_token = oc_url.split(':')[-1]
            token = jwt.decode(raw_token,
                               JWT_SIGNING_SECRET_PLONE,
                               algorithms=('HS256', ))
            self.assertEqual(expected_token, token)

            self.lock_document(browser, raw_token, self.document)

            self.login(self.meeting_user, browser)
            browser.open(self.document)
            self.assertIn(self.locked_message, info_messages())
            self.assertNotIn(self.unlockable_message, info_messages())

            self.login(self.manager, browser)
            browser.open(self.document)
            self.assertNotIn(self.locked_message, info_messages())
            self.assertIn(self.unlockable_message, info_messages())
示例#3
0
    def test_issuing_key_via_manage_service_keys_view(self, browser):
        browser.login().open(view='@@manage-service-keys')
        browser.find('Issue new service key').click()

        with freeze(datetime(2018, 1, 1, 15, 30)):
            browser.fill({
                'Title': 'My new key',
                'IP Range': '192.168.0.0/16',
            }).find('Issue key').click()

        self.assertEqual(1, len(info_messages()))
        match = re.match('Key created: (.*)', info_messages()[0])
        self.assertTrue(match)
        displayed_key_id = match.group(1)

        storage = CredentialStorage(self.plugin)
        self.assertEqual(1, len(storage.list_service_keys(TEST_USER_ID)))
        service_key = storage.list_service_keys(TEST_USER_ID)[0]

        self.assertEqual(displayed_key_id, service_key['key_id'])
        self.assertEqual('My new key', service_key['title'])
        self.assertEqual(datetime(2018, 1, 1, 15, 30), service_key['issued'])
        self.assertEqual(TEST_USER_ID, service_key['user_id'])
        self.assertIn('client_id', service_key)
        self.assertEqual('192.168.0.0/16', service_key['ip_range'])
        self.assertIn('public_key', service_key)
    def test_unlock_button_available_only_for_managers(self, browser):
        with freeze():
            self.login(self.regular_user, browser)
            with freeze(FREEZE_DATE):
                oc_url = self.fetch_document_checkout_oc_url(browser, self.document)

            expected_token = {
                u'action': u'checkout',
                u'documents': [u'createtreatydossiers000000000002'],
                u'exp': 4121033100,
                u'sub': u'kathi.barfuss',
                u'url': u'http://nohost/plone/oc_checkout',
                }
            raw_token = oc_url.split(':')[-1]
            token = jwt.decode(raw_token, JWT_SIGNING_SECRET_PLONE, algorithms=('HS256',))
            self.assertEqual(expected_token, token)

            self.lock_document(browser, raw_token, self.document)

            self.login(self.meeting_user, browser)
            browser.open(self.document)
            self.assertIn(self.locked_message, info_messages())
            self.assertNotIn(self.unlockable_message, info_messages())

            self.login(self.manager, browser)
            browser.open(self.document)
            self.assertNotIn(self.locked_message, info_messages())
            self.assertIn(self.unlockable_message, info_messages())
示例#5
0
    def test_issuing_key_displays_private_key_for_download(self, browser):
        browser.login().open(view='@@manage-service-keys')
        browser.find('Issue new service key').click()

        browser.fill({
            'Title': 'My new key',
            'IP Range': '192.168.0.0/16',
        }).find('Issue key').click()

        self.assertEqual(1, len(info_messages()))
        match = re.match('Key created: (.*)', info_messages()[0])
        self.assertTrue(match)

        storage = CredentialStorage(self.plugin)
        self.assertEqual(1, len(storage.list_service_keys(TEST_USER_ID)))
        key = storage.list_service_keys(TEST_USER_ID)[0]

        self.assertTrue('Download your service key.' in browser.contents)
        self.assertTrue('My new key' in browser.contents)

        json_keyfile = browser.css('.json-keyfile').first
        keyfile_data = json.loads(json_keyfile.text)
        self.assertEquals(
            set([
                'key_id', 'client_id', 'issued', 'user_id', 'token_uri',
                'private_key'
            ]), set(keyfile_data.keys()))

        # TODO: Assert on private key contents, if possible
        self.assertEqual(key['key_id'], keyfile_data['key_id'])
        self.assertEqual(key['issued'].isoformat(), keyfile_data['issued'])
        self.assertEqual(TEST_USER_ID, keyfile_data['user_id'])
        self.assertEqual('http://nohost/plone/@@oauth2-token',
                         keyfile_data['token_uri'])
    def test_status_message_shown_when_local_roles_on_subdossier_are_copied(self, browser):
        assignment_type = ASSIGNMENT_VIA_SHARING
        assignment_class = RoleAssignment.registry[assignment_type]

        self.login(self.administrator, browser=browser)

        browser.open(self.dossier,
                     data=self.make_path_param(self.subdossier), view="copy_items")
        browser.open(self.empty_repofolder)
        browser.click_on('Paste')

        self.assertItemsEqual(info_messages(),
                              ["Objects from clipboard successfully pasted."])

        manager = RoleAssignmentManager(self.subsubdossier)
        manager.add_or_update_assignment(
            assignment_class(self.regular_user.id,
                             ['Reader', 'Editor', 'Contributor']))
        manager = RoleAssignmentManager(self.subsubdossier)
        assignments = manager.get_assignments_by_cause(assignment_type)
        self.assertEqual(1, len(assignments))

        browser.open(self.dossier,
                     data=self.make_path_param(self.subdossier), view="copy_items")
        browser.open(self.empty_repofolder)
        browser.click_on('Paste')

        self.assertItemsEqual(info_messages(),
                              ["Some local roles were copied with the objects",
                               "Objects from clipboard successfully pasted."])
示例#7
0
 def test_lockinfo_is_visible_for_lock_owner(self, browser):
     self.login(self.regular_user, browser=browser)
     browser.open(self.document)
     self.assertEquals([], info_messages())
     lockable = ILockable(self.document)
     lockable.lock()
     browser.open(self.document)
     self.assertEquals([self.lock_message], info_messages())
示例#8
0
 def test_unlock_button_is_visible_for_manager(self, browser):
     self.login(self.regular_user, browser=browser)
     browser.open(self.document)
     self.assertEquals([], info_messages())
     lockable = ILockable(self.document)
     lockable.lock()
     self.login(self.manager, browser=browser)
     browser.open(self.document)
     self.assertEquals([self.lock_message + self.unlock_message], info_messages())
示例#9
0
    def test_revoke_action_displays_success_message(self, browser):
        # revoke action redirects to the current task and displays a success
        # message.
        self.login(self.manager, browser)
        self.set_workflow_state('task-state-tested-and-closed', self.subtask)

        browser.open(self.subtask)
        self.assertEqual([], info_messages())

        browser.click_on("Revoke permissions")
        self.assertIn('Permissions have been succesfully revoked',
                      info_messages())
        self.assertEqual(self.subtask, browser.context)
示例#10
0
    def test_proposal_submission_works_correctly(self, browser):
        committee = create(Builder('committee').titled('My committee'))
        document = create(Builder('document')
                          .within(self.dossier)
                          .titled(u'A Document')
                          .with_dummy_content())
        proposal = create(Builder('proposal')
                          .within(self.dossier)
                          .titled(u'My Proposal')
                          .having(committee=committee.load_model())
                          .relate_to(document))

        self.assertSequenceEqual([], committee.listFolderContents())

        browser.login().open(proposal)

        browser.open(proposal, view='tabbedview_view-overview')
        browser.css('#pending-submitted').first.click()

        self.assertEqual(['Proposal successfully submitted.'], info_messages())

        proposal_model = proposal.load_model()

        # submitted proposal created
        self.assertEqual(1, len(committee.listFolderContents()))
        submitted_proposal = committee.listFolderContents()[0]

        # model synced
        self.assertEqual(proposal_model, submitted_proposal.load_model())
        self.assertEqual(Oguid.for_object(submitted_proposal),
                         proposal_model.submitted_oguid)
        self.assertEqual('submitted', proposal_model.workflow_state)

        # document copied
        self.assertEqual(1, len(submitted_proposal.get_documents()))
        submitted_document = submitted_proposal.get_documents()[0]
        self.assertEqual(document.Title(), submitted_document.Title())
        self.assertEqual(document.file.filename,
                         submitted_document.file.filename)

        self.assertSubmittedDocumentCreated(proposal, document, submitted_document)

        # document should have custom lock message
        browser.open(submitted_document)
        self.assertEqual(
            ['This document has been submitted as a copy of A Document and '
             'cannot be edited directly.'],
            info_messages())
        self.assertEqual(
            document.absolute_url(),
            browser.css('.portalMessage.info a').first.get('href'))
示例#11
0
    def test_proposal_submission_works_correctly(self, browser):
        committee = create(Builder('committee').titled('My committee'))
        document = create(Builder('document')
                          .within(self.dossier)
                          .titled(u'A Document')
                          .with_dummy_content())
        proposal = create(Builder('proposal')
                          .within(self.dossier)
                          .titled(u'My Proposal')
                          .having(committee=committee.load_model())
                          .relate_to(document))

        self.assertSequenceEqual([], committee.listFolderContents())

        browser.login().open(proposal)

        browser.open(proposal, view='tabbedview_view-overview')
        browser.css('#pending-submitted').first.click()

        self.assertEqual(['Proposal successfully submitted.'], info_messages())

        proposal_model = proposal.load_model()

        # submitted proposal created
        self.assertEqual(1, len(committee.listFolderContents()))
        submitted_proposal = committee.listFolderContents()[0]

        # model synced
        self.assertEqual(proposal_model, submitted_proposal.load_model())
        self.assertEqual(Oguid.for_object(submitted_proposal),
                         proposal_model.submitted_oguid)
        self.assertEqual('submitted', proposal_model.workflow_state)

        # document copied
        self.assertEqual(1, len(submitted_proposal.get_documents()))
        submitted_document = submitted_proposal.get_documents()[0]
        self.assertEqual(document.Title(), submitted_document.Title())
        self.assertEqual(document.file.filename,
                         submitted_document.file.filename)

        self.assertSubmittedDocumentCreated(proposal, document, submitted_document)

        # document should have custom lock message
        browser.open(submitted_document)
        self.assertEqual(
            ['This document has been submitted as a copy of A Document and '
             'cannot be edited directly.'],
            info_messages())
        self.assertEqual(
            document.absolute_url(),
            browser.css('.portalMessage.info a').first.get('href'))
 def test_copy_works_without_being_able_to_delete(self, browser):
     folder = create(self.folder_builder())
     self.revoke_permission('Delete portal content', on=folder)
     browser.login().open(folder)
     self.assertFalse(api.user.has_permission("Delete portal content", obj=folder))
     self.assertTrue(api.user.has_permission("Copy or Move", obj=folder))
     browser.find("Copy").click()
     if IS_PLONE_5_OR_GREATER:
         self.assertEqual(['copied.'], statusmessages.info_messages())
     else:
         if self.is_dexterity_test():
             self.assertEquals([u'dxfolder copied.'], statusmessages.info_messages())
         else:
             self.assertEquals([u'folder copied.'], statusmessages.info_messages())
    def test_cannot_copy_dossier_containing_checked_out_document(self, browser):
        self.login(self.regular_user, browser=browser)
        data = self.make_path_param(self.empty_dossier, self.dossier)

        browser.open(self.leaf_repofolder, data=data, view='copy_items')
        self.assertEqual(self.leaf_repofolder.absolute_url(), browser.url)
        self.assertEqual(['Selected objects successfully copied.'], info_messages())
        self.assertEqual([], error_messages())

        self.checkout_document(self.document)
        browser.open(self.leaf_repofolder, data=data, view='copy_items')
        self.assertEqual(self.leaf_repofolder.absolute_url(), browser.url)
        self.assertEqual([], info_messages())
        self.assertEqual(['Checked out documents cannot be copied.'],
                         error_messages())
示例#14
0
    def test_close_and_create_new_period_new(self, browser):
        self.login(self.committee_responsible, browser)

        browser.open(self.committee)
        browser.find('Close current period').click()

        browser.fill({'Title': u'Old',
                      'Start date': '01.01.2012',
                      'End date': '31.12.2012'}).submit()
        browser.fill({'Title': u'New',
                      'Start date': '01.01.2013',
                      'End date': '31.12.2013'}).submit()

        self.assertEqual(["Record created"], info_messages())

        committee_model = browser.context.load_model()  # refresh model
        self.assertEqual(2, len(committee_model.periods))
        old_period = committee_model.periods[0]
        new_period = committee_model.periods[1]

        self.assertEqual('closed', old_period.workflow_state)
        self.assertEqual(u'Old', old_period.title)
        self.assertEqual(date(2012, 1, 1), old_period.date_from)
        self.assertEqual(date(2012, 12, 31), old_period.date_to)
        self.assertEqual('active', new_period.workflow_state)
        self.assertEqual(u'New', new_period.title)
        self.assertEqual(date(2013, 1, 1), new_period.date_from)
        self.assertEqual(date(2013, 12, 31), new_period.date_to)
示例#15
0
    def test_add_meeting_and_dossier(self, browser):
        # create meeting
        browser.login().open(self.committee, view='add-meeting')
        browser.fill({
            'Start': datetime(2010, 1, 1, 10),
            'End': datetime(2010, 1, 1, 11),
            'Location': 'Somewhere',
        }).submit()

        # create dossier
        self.assertEqual(u'Meeting on Jan 01, 2010',
                         browser.find('Title').value)
        browser.find('Save').click()

        # back to meeting page
        self.assertEqual(
            [u'The meeting and its dossier were created successfully'],
            info_messages())
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1#meetings',
            browser.url)

        committee_model = self.committee.load_model()
        self.assertEqual(1, len(committee_model.meetings))
        meeting = committee_model.meetings[0]

        self.assertEqual(self.localized_datetime(2010, 1, 1, 10), meeting.start)
        self.assertEqual(self.localized_datetime(2010, 1, 1, 11), meeting.end)
        self.assertEqual('Somewhere', meeting.location)
        self.assertEqual([Member.get(self.peter.member_id)],
                         meeting.participants)
        dossier = meeting.dossier_oguid.resolve_object()
        self.assertIsNotNone(dossier)
        self.assertEquals(u'Meeting on Jan 01, 2010', dossier.title)
        self.assertIsNotNone(meeting.modified)
    def test_can_be_added(self, browser):
        browser.login().open(self.root)
        factoriesmenu.add('Disposition')
        browser.fill({'Dossiers': [self.dossier1, self.dossier3]})
        browser.find('Save').click()

        self.assertEquals(['Item created'], info_messages())
示例#17
0
    def test_issue_key_form_handles_cancelling(self, browser):
        browser.login().open(view='@@manage-service-keys')
        browser.find('Issue new service key').click()
        browser.find('Cancel').click()

        assert_no_error_messages()
        self.assertEqual(['Key creation cancelled.'], info_messages())
示例#18
0
    def test_close_and_create_new_period_new(self, browser):
        self.login(self.committee_responsible, browser)

        browser.open(self.committee)
        browser.find('Close current period').click()

        browser.fill({
            'Title': u'Old',
            'Start date': '01.01.2012',
            'End date': '31.12.2012'
        }).submit()
        browser.fill({
            'Title': u'New',
            'Start date': '01.01.2013',
            'End date': '31.12.2013'
        }).submit()

        self.assertEqual(["Record created"], info_messages())

        committee_model = browser.context.load_model()  # refresh model
        self.assertEqual(2, len(committee_model.periods))
        old_period = committee_model.periods[0]
        new_period = committee_model.periods[1]

        self.assertEqual('closed', old_period.workflow_state)
        self.assertEqual(u'Old', old_period.title)
        self.assertEqual(date(2012, 1, 1), old_period.date_from)
        self.assertEqual(date(2012, 12, 31), old_period.date_to)
        self.assertEqual('active', new_period.workflow_state)
        self.assertEqual(u'New', new_period.title)
        self.assertEqual(date(2013, 1, 1), new_period.date_from)
        self.assertEqual(date(2013, 12, 31), new_period.date_to)
    def test_sender(self, browser):
        intercepted_data = {}

        class MockedReceiverView(BrowserView):
            def __call__(self):
                intercepted_data['jsondata'] = self.request.form.get(
                    'jsondata')
                return createResponse(SuccessState())

        config = IConfig(self.portal)
        config.appendRealm(
            Realm(1, self.portal.absolute_url(), SITE_OWNER_NAME,
                  SITE_OWNER_PASSWORD))
        transaction.commit()

        with view_registered(MockedReceiverView,
                             'global_statusmessage_config_receiver',
                             required=(IPloneSiteRoot, Interface)):
            browser.login(SITE_OWNER_NAME).open(
                view='@@global_statusmessage_config')
            browser.fill(self.form_data)
            browser.click_on('Save and publish')

        self.assertDictEqual(
            self.expected_settings,
            encode_after_json(json.loads(intercepted_data['jsondata'])))

        self.assertEqual(['Changes saved and published.'], info_messages())
    def test_edit_org_role_particpation_roles(self, browser):
        org_role = create(
            Builder('org_role').having(person=self.peter,
                                       organization=self.meier_ag,
                                       function=u'cheffe'))
        participation = create(
            Builder('org_role_participation').for_dossier(
                self.dossier).for_org_role(org_role))
        create(
            Builder('participation_role').having(participation=participation,
                                                 role=u'final-drawing'))

        browser.login().open(self.dossier,
                             view=u'tabbedview_view-participations')
        browser.click_on('Edit')

        field = browser.forms['form'].find_field('Roles')
        self.assertEquals(['Final drawing', 'Participation', 'Regard'],
                          field.options)

        browser.fill({'Roles': ['Participation', 'Regard']})
        browser.click_on('Save')

        self.assertEquals(['Changes saved'], info_messages())
        self.assertEquals('http://nohost/plone/dossier-1#participations',
                          browser.url)
        self.assertItemsEqual(
            ['participation', 'regard'],
            [role.role for role in Participation.query.first().roles])
示例#21
0
    def test_adding_dossiertemplate_works_properly(self, browser):
        browser.login().open(self.portal)
        factoriesmenu.add('Dossier template')
        browser.fill({'Title': 'Template'}).submit()

        self.assertEquals(['Item created'], info_messages())
        self.assertEquals(['Template'], browser.css('h1').text)
示例#22
0
    def test_close_meeting(self, browser):
        close_meeting_button_name = 'Close meeting'

        meeting = create(Builder('meeting')
                         .having(committee=self.committee_model)
                         .link_with(self.meeting_dossier))
        create(Builder('agenda_item').having(meeting=meeting,
                                             title='Mach ize'))
        create(Builder('agenda_item').having(meeting=meeting,
                                             title='Oebbis in revision',
                                             workflow_state='revision'))

        browser.login().open(meeting.get_url())
        browser.find(close_meeting_button_name).click()

        meeting = Meeting.query.get(meeting.meeting_id)
        self.assertEqual('closed', meeting.workflow_state)
        self.assertEqual(1, meeting.agenda_items[0].decision_number)
        self.assertEqual(1, meeting.meeting_number)

        # javascript redirects upon close, we need to do so manually here ...
        browser.open(meeting.get_url())
        self.assertEqual(
            [u'The meeting C\xf6mmunity meeting has been successfully '
             u'closed, the excerpts have been generated and sent back to the '
             u'initial dossier.'],
            info_messages())
        self.assertIsNone(browser.find(close_meeting_button_name))
    def test_only_expired_dossiers_can_be_added(self, browser):
        self.login(self.records_manager, browser)

        data = {
            'paths:list': obj2paths([self.expired_dossier]),
            '_authenticator': createToken()
        }

        self.assertEqual(date(2000, 12, 31),
                         IDossier(self.expired_dossier).end)

        with freeze(datetime(2001, 1, 1)):
            browser.open(self.repository_root,
                         view='++add++opengever.disposition.disposition',
                         data=data)

            browser.find('Save').click()

            self.assertEquals(['There were some errors.'], error_messages())
            self.assertEquals([
                'The retention period of the selected dossiers is not expired.'
            ],
                              browser.css('.fieldErrorBox .error').text)

        with freeze(datetime(2021, 1, 1)):
            browser.open(self.repository_root,
                         view='++add++opengever.disposition.disposition',
                         data=data)

            browser.find('Save').click()

            self.assertEquals([], error_messages())
            self.assertEquals(['Item created'], info_messages())
示例#24
0
    def test_error_for_untrashable_documents(self, browser):
        trashable = create(
            Builder('document').within(
                self.dossier).titled(u'Trashable document'))
        untrashable = create(
            Builder('document').within(
                self.dossier).titled(u'Untrashable document'))
        # Remove trash permission from all users.
        Permission('opengever.trash: Trash content', [], untrashable).setRoles(
            ())
        transaction.commit()

        data = {
            'paths:list': [
                '/'.join(trashable.getPhysicalPath()),
                '/'.join(untrashable.getPhysicalPath())
            ],
            '_authenticator':
            createToken()
        }
        browser.login().open(self.dossier, view="trashed", data=data)

        self.assertEquals([u'the object Trashable document trashed'],
                          info_messages())
        self.assertEquals([u'Trashing Untrashable document is forbidden'],
                          error_messages())
        self.assertEquals('http://nohost/plone/dossier-1#documents',
                          browser.url)
示例#25
0
    def test_redirects_to_portal_when_current_user_has_no_longer_view_permission(
            self, browser):
        self.login(self.regular_user, browser=browser)

        api.content.disable_roles_acquisition(obj=self.dossier)
        self.assign_task(self.secretariat_user, u'Thats a job for you.')

        manager = RoleAssignmentManager(self.task)
        self.assertEqual([{
            'cause': ASSIGNMENT_VIA_TASK,
            'roles': ['Editor'],
            'reference': Oguid.for_object(self.task).id,
            'principal': 'jurgen.konig'
        }, {
            'cause': ASSIGNMENT_VIA_TASK_AGENCY,
            'roles': ['Editor'],
            'reference': Oguid.for_object(self.task).id,
            'principal': u'fa_inbox_users'
        }], manager.storage._storage())

        self.assertEqual(self.portal.absolute_url(), browser.url)
        self.assertEqual([
            'Task successfully reassigned. You are no longer permitted to '
            'access the task.'
        ], info_messages())
示例#26
0
    def test_break_permission_inheritance(self, browser):
        browser.login().open(self.repo_folder, view='sharing')
        browser.fill({'Inherit permissions from higher levels': False})
        browser.click_on('Save')

        self.assertEquals(['Changes saved.'], info_messages())
        self.assertTrue(self.repo_folder.__ac_local_roles_block__)
    def test_only_expired_dossiers_can_be_added(self, browser):
        self.login(self.records_manager, browser)

        data = {'paths:list': obj2paths([self.expired_dossier]),
                '_authenticator': createToken()}

        self.assertEqual(date(2000, 12, 31), IDossier(self.expired_dossier).end)

        with freeze(datetime(2001, 1, 1)):
            browser.open(self.repository_root,
                         view='++add++opengever.disposition.disposition',
                         data=data)

            browser.find('Save').click()

            self.assertEquals(['There were some errors.'], error_messages())
            self.assertEquals(
                ['The retention period of the selected dossiers is not expired.'],
                browser.css('.fieldErrorBox .error').text)

        with freeze(datetime(2021, 1, 1)):
            browser.open(self.repository_root,
                         view='++add++opengever.disposition.disposition',
                         data=data)

            browser.find('Save').click()

            self.assertEquals([], error_messages())
            self.assertEquals(['Item created'], info_messages())
示例#28
0
    def test_close_meeting(self, browser):
        close_meeting_button_name = 'Close meeting'

        meeting = create(Builder('meeting')
                         .having(committee=self.committee_model)
                         .link_with(self.meeting_dossier))
        create(Builder('agenda_item').having(meeting=meeting,
                                             title='Mach ize'))
        create(Builder('agenda_item').having(meeting=meeting,
                                             title='Oebbis in revision',
                                             workflow_state='revision'))

        browser.login().open(meeting.get_url())
        browser.find(close_meeting_button_name).click()

        meeting = Meeting.query.get(meeting.meeting_id)
        self.assertEqual('closed', meeting.workflow_state)
        self.assertEqual(1, meeting.agenda_items[0].decision_number)
        self.assertEqual(1, meeting.meeting_number)

        # javascript redirects upon close, we need to do so manually here ...
        browser.open(meeting.get_url())
        self.assertEqual(
            [u'The meeting C\xf6mmunity meeting has been successfully '
             u'closed, the excerpts have been generated and sent back to the '
             u'initial dossier.'],
            info_messages())
        self.assertIsNone(browser.find(close_meeting_button_name))
示例#29
0
    def test_close_and_create_new_period(self, browser):
        # CommitteeResponsible is assigned globally here for the sake of
        # simplicity
        self.grant('Contributor', 'Editor', 'Reader', 'MeetingUser',
                   'CommitteeResponsible')

        browser.login()
        browser.open(self.committee)
        browser.find('Close current period').click()

        browser.fill({'Title': u'Old',
                      'Start date': '01.01.2012',
                      'End date': '31.12.2012'}).submit()
        browser.fill({'Title': u'New',
                      'Start date': '01.01.2013',
                      'End date': '31.12.2013'}).submit()

        self.assertEqual(["Record created"], info_messages())

        committee_model = browser.context.load_model()  # refresh model
        self.assertEqual(2, len(committee_model.periods))
        old_period = committee_model.periods[0]
        new_period = committee_model.periods[1]

        self.assertEqual('closed', old_period.workflow_state)
        self.assertEqual(u'Old', old_period.title)
        self.assertEqual(date(2012, 1, 1), old_period.date_from)
        self.assertEqual(date(2012, 12, 31), old_period.date_to)
        self.assertEqual('active', new_period.workflow_state)
        self.assertEqual(u'New', new_period.title)
        self.assertEqual(date(2013, 1, 1), new_period.date_from)
        self.assertEqual(date(2013, 12, 31), new_period.date_to)
示例#30
0
    def test_add_meeting_and_dossier(self, browser):
        # create meeting
        browser.login().open(self.committee, view='add-meeting')
        browser.fill({
            'Start': '01.01.2010 10:00',
            'End': '01.01.2010 11:00',
            'Location': 'Somewhere',
        }).submit()

        # create dossier
        self.assertEqual(u'Meeting on Jan 01, 2010',
                         browser.find('Title').value)
        browser.find('Save').click()

        # back to meeting page
        self.assertEqual(
            [u'The meeting and its dossier were created successfully'],
            info_messages())
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1#meetings',
            browser.url)

        committee_model = self.committee.load_model()
        self.assertEqual(1, len(committee_model.meetings))
        meeting = committee_model.meetings[0]

        self.assertEqual(self.localized_datetime(2010, 1, 1, 10), meeting.start)
        self.assertEqual(self.localized_datetime(2010, 1, 1, 11), meeting.end)
        self.assertEqual('Somewhere', meeting.location)
        self.assertEqual([Member.get(self.peter.member_id)],
                         meeting.participants)
        dossier = meeting.dossier_oguid.resolve_object()
        self.assertIsNotNone(dossier)
        self.assertEquals(u'Meeting on Jan 01, 2010', dossier.title)
        self.assertIsNotNone(meeting.modified)
示例#31
0
    def test_word_proposal_can_be_submitted(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()))

        self.assertEqual(Proposal.STATE_PENDING, proposal.get_state())
        self.assertEqual('proposal-state-active',
                         api.content.get_state(proposal))

        browser.login().open(proposal, view='tabbedview_view-overview')
        browser.css('#pending-submitted').first.click()
        self.assertEqual(['Proposal successfully submitted.'], info_messages())
        self.assertEqual(Proposal.STATE_SUBMITTED, proposal.get_state())
        self.assertEqual('proposal-state-submitted',
                         api.content.get_state(proposal))

        submitted_proposal = proposal.load_model().resolve_submitted_proposal()
        self.assertEquals(
            'Fake proposal file body',
            submitted_proposal.get_proposal_document().file.open().read())
    def test_edit_ogs_user_participation_roles(self, browser):
        ogds_user = create(
            Builder('ogds_user').id('peter').having(
                firstname=u'Hans', lastname=u'Peter').as_contact_adapter())

        participation = create(
            Builder('ogds_user_participation').for_dossier(
                self.dossier).for_ogds_user(ogds_user))
        create(
            Builder('participation_role').having(participation=participation,
                                                 role=u'final-drawing'))

        browser.login().open(self.dossier,
                             view=u'tabbedview_view-participations')
        browser.click_on('Edit')

        field = browser.forms['form'].find_field('Roles')
        self.assertEquals(['Final drawing', 'Participation', 'Regard'],
                          field.options)

        browser.fill({'Roles': ['Participation', 'Regard']})
        browser.click_on('Save')

        self.assertEquals(['Changes saved'], info_messages())
        self.assertEquals('http://nohost/plone/dossier-1#participations',
                          browser.url)
        self.assertItemsEqual(
            ['participation', 'regard'],
            [role.role for role in Participation.query.first().roles])
示例#33
0
    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.')
示例#34
0
    def test_outdated_document_can_be_updated(self, browser):
        self.login(self.meeting_user, browser)

        # No initial versions anymore, so have to do two versions
        create_document_version(self.document, 0)
        create_document_version(self.document, 1)

        browser.open(self.document, view='tabbedview_view-overview')

        browser.find('Update document in proposal').click()
        browser.find('Submit Attachments').click()

        self.assertEqual(
            [
                (u'A new submitted version of document'
                 u' Vertr\xe4gsentwurf has been created.'),
            ],
            info_messages(),
        )

        self.assert_submitted_document_created(
            self.proposal,
            self.document,
            submitted_version=1,
        )
示例#35
0
    def test_adding_dossiertemplate_works_properly(self, browser):
        browser.login().open(self.portal)
        factoriesmenu.add('Dossier template')
        browser.fill({'Title': 'Template'}).submit()

        self.assertEquals(['Item created'], info_messages())
        self.assertEquals(['Template'], browser.css('h1').text)
示例#36
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)
示例#37
0
    def test_person_can_be_edited_in_browser(self, browser):
        contactfolder = create(Builder('contactfolder'))

        peter = create(Builder('person')
                       .having(firstname=u'Peter', lastname=u'M\xfcller'))

        browser.login().open(contactfolder, view=peter.wrapper_id)

        browser.find("Edit").click()

        browser.fill({'Salutation': u'Sir',
                      'Academic title': u'Dr',
                      'Firstname': u'Hanspeter',
                      'Lastname': u'Hansj\xf6rg',
                      'Description': u'Pellentesque posuere.'}).submit()

        self.assertEquals([u'Changes saved'], info_messages())

        person = Person.get(peter.person_id)
        self.assertIsNotNone(person)
        self.assertEqual(u'Sir', person.salutation)
        self.assertEqual(u'Dr', person.academic_title)
        self.assertEqual(u'Hanspeter', person.firstname)
        self.assertEqual(u'Hansj\xf6rg', person.lastname)
        self.assertEqual(u'Pellentesque posuere.', person.description)
示例#38
0
    def test_decide_agenda_item_creates_locked_excerpt_in_dossier(self, browser):
        self.setup_excerpt_template()
        proposal = self.setup_proposal()
        # schedule
        view = 'unscheduled_proposals/{}/schedule'.format(
            proposal.load_model().proposal_id)

        browser.login().open(self.meeting_wrapper, view=view)
        agenda_item = AgendaItem.query.first()
        browser.login().open(
            self.meeting_wrapper,
            view='agenda_items/{}/decide'.format(agenda_item.agenda_item_id),
            data={'_authenticator': createToken()})

        agenda_item = AgendaItem.query.first()  # refresh
        proposal = agenda_item.proposal
        excerpt_in_dossier = proposal.excerpt_document.resolve_document()
        lockable = ILockable(excerpt_in_dossier)
        self.assertTrue(lockable.locked())
        self.assertTrue(lockable.can_safely_unlock(MEETING_EXCERPT_LOCK))

        browser.open(excerpt_in_dossier)
        self.assertEqual(u'This document is a copy of the excerpt Fooo - '
                         u'C\xf6mmunity meeting from the meeting C\xf6mmunity '
                         u'meeting and cannot be edited directly.',
                         info_messages()[0])
        message_links = browser.css('.portalMessage.info a')
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1/submitted-proposal-1/document-3',
            message_links[0].get('href'))
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1/meeting-1/view',
            message_links[1].get('href'))
示例#39
0
    def test_edit_ogs_user_participation_roles(self, browser):
        ogds_user = create(Builder('ogds_user')
                           .id('peter')
                           .having(firstname=u'Hans', lastname=u'Peter')
                           .as_contact_adapter())

        participation = create(Builder('ogds_user_participation')
                               .for_dossier(self.dossier)
                               .for_ogds_user(ogds_user))
        create(Builder('participation_role').having(
            participation=participation, role=u'final-drawing'))

        browser.login().open(self.dossier,
                             view=u'tabbedview_view-participations')
        browser.click_on('Edit')

        field = browser.forms['form'].find_field('Roles')
        self.assertEquals(['Final drawing', 'Participation', 'Regard'],
                          field.options)

        browser.fill({'Roles': ['Participation', 'Regard']})
        browser.click_on('Save')

        self.assertEquals(['Changes saved'], info_messages())
        self.assertEquals(
            'http://nohost/plone/dossier-1#participations', browser.url)
        self.assertItemsEqual(
            ['participation', 'regard'],
            [role.role for role in Participation.query.first().roles])
示例#40
0
    def test_edit_org_role_particpation_roles(self, browser):
        org_role = create(Builder('org_role').having(
            person=self.peter, organization=self.meier_ag, function=u'cheffe'))
        participation = create(Builder('org_role_participation')
                               .for_dossier(self.dossier)
                               .for_org_role(org_role))
        create(Builder('participation_role').having(
            participation=participation, role=u'final-drawing'))

        browser.login().open(self.dossier,
                             view=u'tabbedview_view-participations')
        browser.click_on('Edit')

        field = browser.forms['form'].find_field('Roles')
        self.assertEquals(['Final drawing', 'Participation', 'Regard'],
                          field.options)

        browser.fill({'Roles': ['Participation', 'Regard']})
        browser.click_on('Save')

        self.assertEquals(['Changes saved'], info_messages())
        self.assertEquals(
            'http://nohost/plone/dossier-1#participations', browser.url)
        self.assertItemsEqual(
            ['participation', 'regard'],
            [role.role for role in Participation.query.first().roles])
示例#41
0
    def test_outdated_document_can_be_updated(self, browser):
        self.login(self.meeting_user, browser)

        # No initial versions anymore, so have to do two versions
        create_document_version(self.document, 0)
        create_document_version(self.document, 1)

        browser.open(self.document, view='tabbedview_view-overview')

        browser.find('Update document in proposal').click()
        browser.find('Submit Attachments').click()

        self.assertEqual(
            [
                (
                    u'A new submitted version of document'
                    u' Vertr\xe4gsentwurf has been created.'
                    ),
                ],
            info_messages(),
            )

        self.assert_submitted_document_created(
            self.proposal,
            self.document,
            submitted_version=1,
            )
    def test_decide_agenda_item_creates_locked_excerpt_in_dossier(
            self, browser):
        self.setup_excerpt_template()
        proposal = self.setup_proposal()
        # schedule
        view = 'unscheduled_proposals/{}/schedule'.format(
            proposal.load_model().proposal_id)

        browser.login().open(self.meeting_wrapper, view=view)
        agenda_item = AgendaItem.query.first()
        browser.login().open(self.meeting_wrapper,
                             view='agenda_items/{}/decide'.format(
                                 agenda_item.agenda_item_id),
                             data={'_authenticator': createToken()})

        agenda_item = AgendaItem.query.first()  # refresh
        proposal = agenda_item.proposal
        excerpt_in_dossier = proposal.excerpt_document.resolve_document()
        lockable = ILockable(excerpt_in_dossier)
        self.assertTrue(lockable.locked())
        self.assertTrue(lockable.can_safely_unlock(MEETING_EXCERPT_LOCK))

        browser.open(excerpt_in_dossier)
        self.assertEqual(
            u'This document is a copy of the excerpt Fooo - '
            u'C\xf6mmunity meeting from the meeting C\xf6mmunity '
            u'meeting and cannot be edited directly.',
            info_messages()[0])
        message_links = browser.css('.portalMessage.info a')
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1/submitted-proposal-1/document-3',
            message_links[0].get('href'))
        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1/meeting-1/view',
            message_links[1].get('href'))
    def test_sender(self, browser):
        intercepted_data = {}

        class MockedReceiverView(BrowserView):
            def __call__(self):
                intercepted_data['jsondata'] = self.request.form.get('jsondata')
                return createResponse(SuccessState())

        config = IConfig(self.portal)
        config.appendRealm(Realm(1, self.portal.absolute_url(), SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
        transaction.commit()

        with view_registered(MockedReceiverView, 'global_statusmessage_config_receiver',
                             required=(IPloneSiteRoot, Interface)):
            browser.login(SITE_OWNER_NAME).open(view='@@global_statusmessage_config')
            browser.fill(self.form_data)
            browser.click_on('Save and publish')

        self.assertDictEqual(
            self.expected_settings,
            encode_after_json(json.loads(intercepted_data['jsondata']))
        )

        self.assertEqual(
            ['Changes saved and published.'],
            info_messages()
        )
示例#44
0
    def test_manual_excerpt_can_be_generated(self, browser):
        browser.login().open(self.meeting.get_url())

        browser.css('.generate-excerpt').first.click()
        browser.fill({
            'agenda_item-1.include:record': True,
            'Target dossier': self.dossier
        })
        browser.find('Save').click()

        self.assertEqual([
            u'Excerpt for meeting C\xf6mmunity meeting has '
            'been generated successfully'
        ], info_messages())
        # refresh
        meeting = Meeting.get(self.meeting.meeting_id)
        self.assertEqual(1, len(meeting.excerpt_documents))
        document = meeting.excerpt_documents[0]
        self.assertEqual(0, document.generated_version)

        self.assertEqual(self.meeting.get_url(), browser.url,
                         'should be on meeting view')

        self.assertEqual(1, len(browser.css('.excerpts li a.document_link')),
                         'generated document should be linked')
        self.assertEqual([u'Protocol Excerpt-C\xf6mmunity meeting'],
                         browser.css('.excerpts li a.document_link').text)
示例#45
0
    def test_adding_subdossiers_is_allowed(self, browser):
        browser.login().open(self.dossier)
        factoriesmenu.add('Subdossier')
        browser.fill({'Title': u'Sub 1', 'Responsible': TEST_USER_ID})
        browser.click_on('Save')

        self.assertEquals(['Item created'], info_messages())
示例#46
0
    def test_statusmessage_if_copy_mail_success(self, browser):
        self.login(self.regular_user, browser=browser)
        browser.open(self.mail, view='copy_item')

        self.assertEqual(self.mail.absolute_url(), browser.url)
        self.assertEqual(['Selected objects successfully copied.'],
                         info_messages())
示例#47
0
    def test_edit_period(self, browser):
        browser.login().open(self.committee, view="tabbedview_view-periods")
        browser.find("Edit").click()
        browser.fill({"Start date": "January 20, 2016"}).submit()

        self.assertEqual(["Changes saved"], info_messages())
        self.assertEqual(date(2016, 1, 20), Period.query.one().date_from)
示例#48
0
    def test_can_be_added(self, browser):
        browser.login().open(self.root)
        factoriesmenu.add('Disposition')
        browser.fill({'Dossiers': [self.dossier1, self.dossier3]})
        browser.find('Save').click()

        self.assertEquals(['Item created'], info_messages())
示例#49
0
    def test_redirects_to_document_itself_when_view_is_called_on_a_document(self, browser):
        doc = create(Builder('document').within(self.dossier).checked_out())
        browser.login().open(doc, {'_authenticator': createToken()},
                             view='cancel_document_checkouts', )

        self.assertEquals(doc, browser.context)
        self.assertEquals([u'Cancel checkout: Testdokum\xe4nt'],
                          info_messages())
示例#50
0
    def test_responsible_is_mandatory(self, browser):
        self.login(self.regular_user, browser=browser)
        browser.open(self.task, view='assign-task')
        browser.click_on('Assign')

        self.assertEqual([], info_messages())
        errors = browser.css("#formfield-form-widgets-transition .error")
        self.assertEqual(['Required input is missing.'], errors.text)
示例#51
0
    def test_edit_period(self, browser):
        self.login(self.committee_responsible, browser)
        browser.open(self.committee, view='tabbedview_view-periods')
        browser.find('Edit').click()
        browser.fill({'Start date': '20.01.2016'}).submit()

        self.assertEqual(['Changes saved'], info_messages())
        self.assertEqual(date(2016, 1, 20), Period.query.first().date_from)
示例#52
0
    def test_editing_a_team(self, browser):
        self.login(self.administrator, browser=browser)
        browser.open(self.contactfolder, view='team-1/edit')
        browser.fill({'Title': u'Projekt \xdcberbaung Dorf S\xfcd'})
        browser.click_on('Save')

        self.assertEquals(['Changes saved'], info_messages())
        self.assertEquals(u'Projekt \xdcberbaung Dorf S\xfcd', Team.get('1').title)
示例#53
0
    def test_archive_form_is_omitted_when_resolving_subdossiers(self, browser):
        self.login(self.secretariat_user, browser)

        resolve_dossier(self.subdossier, browser)

        self.assertEquals(self.subdossier.absolute_url(), browser.url)
        self.assertEquals(['The subdossier has been succesfully resolved.'],
                          info_messages())
示例#54
0
    def test_archive_form_is_omitted_for_sites_without_filing_number_support(self, browser):
        self.login(self.secretariat_user, browser)

        resolve_dossier(self.empty_dossier, browser)

        self.assertEquals(self.empty_dossier.absolute_url(), browser.url)
        self.assertEquals(['The dossier has been succesfully resolved.'],
                          info_messages())
示例#55
0
    def test_redirects_back_and_show_statusmessage_if_copy_success(self, browser):
        self.login(self.regular_user, browser=browser)

        data = self.make_path_param(self.document, self.mail)
        browser.open(self.dossier, data=data, view='copy_items')

        self.assertEqual(self.dossier.absolute_url(), browser.url)
        self.assertEqual(['Selected objects successfully copied.'], info_messages())
示例#56
0
    def test_adding_subdossiers_is_allowed(self, browser):
        browser.login().open(self.dossier)
        factoriesmenu.add('Subdossier')
        browser.fill({'Title': u'Sub 1',
                      'Responsible': TEST_USER_ID})
        browser.click_on('Save')

        self.assertEquals(['Item created'], info_messages())