def selftest(self):
        with browser:
            self.testserverctl('zodb_setup')
            with browser.expect_unauthorized():
                browser.open(self.plone_url)

            browser.fill({'Benutzername': SITE_OWNER_NAME,
                          'Passwort': SITE_OWNER_PASSWORD}).submit()

            browser.replace_request_header('Accept', 'application/json')
            browser.replace_request_header('Content-Type', 'application/json')

            data = {'@type': 'opengever.dossier.businesscasedossier',
                    'title': u'Gesch\xe4ftsdossier',
                    'responsible': 'kathi.barfuss'}
            browser.open(self.plone_url + 'ordnungssystem/rechnungspruefungskommission',
                         method='POST',
                         data=json.dumps(data))
            dossier_url = browser.json['@id']

            browser.open(dossier_url)
            self.assertDictContainsSubset(
                {u'title': u'Gesch\xe4ftsdossier',
                 u'modified': u'2018-11-22T14:29:33+00:00',
                 u'UID': u'testserversession000000000000001',
                 u'email': u'*****@*****.**'},
                browser.json)

            self.testserverctl('zodb_teardown')
            self.testserverctl('zodb_setup')

            with browser.expect_http_error(404):
                browser.open(dossier_url)

            self.testserverctl('zodb_teardown')
Пример #2
0
def select_valid_payment_processor():
    assert_step(PAYMENT_PROCESSOR)
    # XXX: "Gegen Rechnung" should be translated to english
    browser.fill({"Gegen Rechnung": "ftw.shop.InvoicePaymentProcessor"})
    import checkout

    return checkout
Пример #3
0
    def test_disable_for_anonymous(self, browser):
        subsite = create(Builder('folder')
                         .titled('The Subsite')
                         .providing(INavigationRoot))

        browser.login().visit(view='global_statusmessage_config')
        browser.fill(
            {'Active': True,
             'Type': 'information',
             'Title': 'Maintenance',
             'Message': 'Scheduled Maintenance'}).submit()

        browser.logout().visit(self.portal)
        self.assertTrue(
            statusmessage(),
            'Status should be visible for anonymous by default.')

        browser.login().visit(view='global_statusmessage_config')
        browser.fill(
            {'Show to anonymous users?': False}).submit()

        browser.visit(self.portal)
        self.assertTrue(
            statusmessage(),
            'Status should still visible for logged in users.')

        browser.logout().reload()
        self.assertFalse(
            statusmessage(),
            'Status should no longer be visible for anonymous in users.')
    def test_configuration_form_in_browser(self, browser):
        browser.login().open()

        # Create a service navigation through the configuration form.
        browser.find('Edit').click()
        browser.fill({
            'Service links': [
                {
                    'Label': u'Internal link',
                    'Internal link': self.folder,
                    'Icon': u'Music'
                },
                {
                    'Label': u'External link',
                    'External URL': u'http://www.4teamwork.ch',
                    'Icon': u'Heart'
                },
            ]
        }).save()
        self.assertEqual(
            'http://nohost/plone/a-folder',
            browser.find('Internal link').attrib['href'],
        )
        self.assertEqual(
            'http://www.4teamwork.ch',
            browser.find('External link').attrib['href'],
        )

        # Disable the service navigation
        browser.find('Edit').click()
        browser.fill({'Disable service links': True}).save()
        self.assertIsNone(browser.find('Internal link'))
        self.assertIsNone(browser.find('External link'))
    def test_editing_mail_with_a_real_name_as_author_dont_change_author_name(self, browser):
        self.login(self.regular_user, browser)
        browser.open(self.mail_eml, view='edit')
        browser.fill({'Author': u'Muster Peter'})
        browser.click_on('Save')

        self.assertEquals('Muster Peter', self.mail_eml.document_author)
Пример #6
0
    def test_exclude_subsite(self, browser):
        subsite = create(Builder('folder')
                         .titled('The Subsite')
                         .providing(INavigationRoot))

        browser.login().visit(view='global_statusmessage_config')
        browser.fill(
            {'Active': True,
             'Type': 'information',
             'Title': 'Maintenance',
             'Message': 'Scheduled Maintenance',
             'Exclude sites': ['The Subsite']}).submit()


        browser.visit(self.portal)
        self.assertTrue(
            statusmessage(),
            'Status message should be visible on site root.')

        page_on_site_root = create(Builder('page'))
        browser.visit(page_on_site_root)
        self.assertTrue(
            statusmessage(),
            'Status message should be visible on pages within site root.')

        browser.visit(subsite)
        self.assertFalse(
            statusmessage(),
            'Status message should not be visible on subsite.')

        page_on_subsite = create(Builder('page').within(subsite))
        browser.visit(page_on_subsite)
        self.assertFalse(
            statusmessage(),
            'Status message should not be visible on pages within subsite.')
    def test_editing_mail_with_a_userid_as_author_resolves_to_fullname(self, browser):
        self.login(self.regular_user, browser)
        browser.open(self.mail_eml, view='edit')
        browser.fill({'Author': u'kathi.barfuss'})
        browser.click_on('Save')

        self.assertEquals(u'B\xe4rfuss K\xe4thi', self.mail_eml.document_author)
        self.assertEquals(u'B\xe4rfuss K\xe4thi', obj2brain(self.mail_eml).document_author)
    def create_mail(self):
        """Add mails over a plone view since builders implement their own
        instance construction.
        """

        with browser(self.app):
            dossier = create(Builder("dossier"))
            browser.login().open(dossier, view="++add++ftw.mail.mail")
            browser.fill({"Raw Message": (MAIL_DATA, "mail.eml", "message/rfc822")}).submit()

            mail = browser.context
            return mail
Пример #9
0
    def test_successfully_add_activity(self, member):
        create(Builder('ogds_user')
               .having(userid='hugo.boss'))

        browser.login('hugo.boss').open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task',
                      'Issuer': TEST_USER_ID,
                      'Responsible': 'inbox:client1',
                      'Task Type': 'comment'})
        browser.css('#form-buttons-save').first.click()

        self.assertEquals([], warning_messages())
        self.assertEquals(['Item created'], info_messages())
    def create_mail(self):
        """Add mails over a plone view since builders implement their own
        instance construction.
        """

        with browser(self.app):
            dossier = create(Builder("dossier"))
            browser.login().open(dossier, view='++add++ftw.mail.mail')
            browser.fill({
                'Raw Message': (MAIL_DATA, 'mail.eml', 'message/rfc822')
            }).submit()

            mail = browser.context
            return mail
Пример #11
0
    def test_info_status_message(self, browser):
        browser.login(SITE_OWNER_NAME).visit(
            view='global_statusmessage_config')
        browser.fill(
            {'Active': True,
             'Type': 'information',
             'Title': 'Maintenance',
             'Message': 'Scheduled maintenance 20PM-22PM'}).submit()

        self.assertEquals(
            {'type': 'information',
             'title': 'Maintenance',
             'message': 'Scheduled maintenance 20PM-22PM'},
            statusmessage())
Пример #12
0
    def test_error_status_message(self, browser):
        browser.login(SITE_OWNER_NAME).visit(
            view='global_statusmessage_config')
        browser.fill(
            {'Active': True,
             'Type': 'error',
             'Title': 'Outage',
             'Message': 'Some parts are not available'}).submit()

        self.assertEquals(
            {'type': 'error',
             'title': 'Outage',
             'message': 'Some parts are not available'},
            statusmessage())
 def make_dropzone_upload(context, file_):
     """The dropzone JS makes a multipart upload with the the file as field named "file".
     The testbrowser does not support making multipart requests directly (we would have to
     create the MIME body ourself), but the form filling does that well.
     Therefore we use an HTML form for uploading.
     """
     html = (
         '<form action="{}/@@dropzone-upload" method="post" enctype="multipart/form-data">'
         '  <input type="file" name="file" />'
         '  <input type="hidden" name="_authenticator" value="{}" />'
         '  <input type="submit" />'
         '</form>').format(context.absolute_url(), createToken())
     defaultbrowser.open(context).parse(html)
     defaultbrowser.fill({'file': file_}).submit()
     return defaultbrowser
Пример #14
0
    def test_successfully_add_activity(self, member):
        create(Builder('ogds_user').having(userid='hugo.boss'))

        browser.login('hugo.boss').open(self.dossier,
                                        view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task', 'Task Type': 'comment'})

        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill('inbox:org-unit-1')
        form.find_widget('Issuer').fill(TEST_USER_ID)

        browser.css('#form-buttons-save').first.click()

        self.assertEquals([], warning_messages())
        self.assertEquals(['Item created'], info_messages())
Пример #15
0
def fill_contact_info():
    assert_step(CONTACT_INFORMATION)
    browser.fill({
        u'Title': 'Sir',
        u'First Name': 'Hugo',
        u'Last Name': 'Boss',
        u'Email': '*****@*****.**',
        u'Street/No.': 'Example Street 15',
        u'Phone number': '001 0101 0101 01',
        u'Zip Code': '3000',
        u'City': 'Bern',
        u'Country': 'Switzerland'
    })
    import checkout
    return checkout
Пример #16
0
    def test_disabling_status_message(self, browser):
        browser.login(SITE_OWNER_NAME).visit(
            view='global_statusmessage_config')
        browser.fill(
            {'Active': True,
             'Type': 'information',
             'Title': 'Maintenance',
             'Message': 'Scheduled maintenance 20PM-22PM'}).submit()
        self.assertTrue(statusmessage(),
                        'Expected a message to be configured.')

        browser.visit(view='global_statusmessage_config')
        browser.fill({'Active': False}).submit()
        self.assertFalse(statusmessage(),
                        'Expected message to be no longer visible.')
Пример #17
0
    def test_configuration_form_in_browser(self, browser):
        browser.login().open()

        # Create a service navigation through the configuration form.
        browser.find('Edit').click()
        browser.fill({
            'Service links': [
                {
                    'Label': u'Internal link',
                    'Internal link': '/a-folder',
                    'Icon': u'Music'
                },
                {
                    'Label': u'External link',
                    'External URL': u'http://www.4teamwork.ch',
                    'Icon': u'Heart'
                },
            ]
        }).save()
        self.assertEqual(
            'http://nohost/plone/a-folder',
            browser.find('Internal link').attrib['href'],
        )
        self.assertEqual(
            'http://www.4teamwork.ch',
            browser.find('External link').attrib['href'],
        )

        # Disable the service navigation
        browser.find('Edit').click()
        browser.fill({
            'Service links': [
                {
                    'Label': u'Internal link',
                    'Internal link': '/a-folder',
                    'Icon': u'Music'
                },
                {
                    'Label': u'External link',
                    'External URL': u'http://www.4teamwork.ch',
                    'Icon': u'Heart'
                },
            ],
            'Disable service links':
            True
        }).save()
        self.assertIsNone(browser.find('Internal link'))
        self.assertIsNone(browser.find('External link'))
Пример #18
0
    def test_shows_message_when_error_happen_during_activity_creation(self, member):
        # Because there exists no OGDS user for the plone user hugo.boss,
        # the notification creation fails.

        browser.login('hugo.boss').open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task',
                      'Issuer': TEST_USER_ID,
                      'Responsible': 'inbox:client1',
                      'Task Type': 'comment'})
        browser.css('#form-buttons-save').first.click()

        self.assertEquals(
            ['A problem has occurred during the notification creation. '
             'Notification could not or only partially produced.'],
            warning_messages())
        self.assertEquals(['Item created'], info_messages())
Пример #19
0
    def test_add_watcher_adds_subscription_for_each_actor(self, member):
        browser.login().open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task',
                      'Responsible': 'inbox:client1',
                      'Task Type': 'comment'})
        browser.css('#form-buttons-save').first.click()

        task = self.dossier.get('task-1')
        resource = notification_center().fetch_resource(task)

        subscriptions = resource.subscriptions

        self.assertItemsEqual(
            [(u'inbox:client1', u'task_responsible'),
             (u'test_user_1_', u'task_issuer')],
            [(sub.watcher.actorid, sub.role) for sub in subscriptions])
Пример #20
0
    def test_shows_message_if_dispatchers_raise_an_exception(self, member):
        create(Builder('ogds_user')
               .having(userid='hugo.boss', email=None)
               .in_group(self.org_unit.users_group))

        browser.login().open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task',
                      'Issuer': TEST_USER_ID,
                      'Responsible': u'hugo.boss',
                      'Task Type': 'comment'})
        browser.css('#form-buttons-save').first.click()

        self.assertEquals(
            ['A problem has occurred during the notification creation. '
             'Notification could not or only partially produced.'],
            warning_messages())
        self.assertEquals(['Item created'], info_messages())
Пример #21
0
    def test_add_watcher_adds_subscription_for_each_actor(self, member):
        browser.login().open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task', 'Task Type': 'comment'})

        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill('inbox:org-unit-1')

        browser.css('#form-buttons-save').first.click()

        task = self.dossier.get('task-1')
        resource = notification_center().fetch_resource(task)

        subscriptions = resource.subscriptions

        self.assertItemsEqual([(u'inbox:org-unit-1', u'task_responsible'),
                               (u'test_user_1_', u'task_issuer')],
                              [(sub.watcher.actorid, sub.role)
                               for sub in subscriptions])
Пример #22
0
def fill_contact_info():
    assert_step(CONTACT_INFORMATION)
    browser.fill(
        {
            u"Title": "Sir",
            u"First Name": "Hugo",
            u"Last Name": "Boss",
            u"Email": "*****@*****.**",
            u"Street/No.": "Example Street 15",
            u"Phone number": "001 0101 0101 01",
            u"Zip Code": "3000",
            u"City": "Bern",
            u"Country": "Switzerland",
        }
    )
    import checkout

    return checkout
Пример #23
0
    def test_shows_message_when_error_happen_during_activity_creation(self, member):
        # Because there exists no OGDS user for the plone user hugo.boss,
        # the notification creation fails.

        browser.login('hugo.boss').open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task',
                      'Task Type': 'comment'})

        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill('inbox:client1')
        form.find_widget('Issuer').fill(TEST_USER_ID)

        browser.css('#form-buttons-save').first.click()

        self.assertEquals(
            ['A problem has occurred during the notification creation. '
             'Notification could not or only partially produced.'],
            warning_messages())
        self.assertEquals(['Item created'], info_messages())
Пример #24
0
    def test_shows_message_if_dispatchers_raise_an_exception(self, member):
        create(
            Builder('ogds_user').having(userid='hugo.boss',
                                        email=None).in_group(
                                            self.org_unit.users_group))

        browser.login().open(self.dossier, view='++add++opengever.task.task')
        browser.fill({'Title': 'Test Task', 'Task Type': 'comment'})

        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill('hugo.boss')
        form.find_widget('Issuer').fill(TEST_USER_ID)

        browser.css('#form-buttons-save').first.click()

        self.assertEquals([
            'A problem has occurred during the notification creation. '
            'Notification could not or only partially produced.'
        ], warning_messages())
        self.assertEquals(['Item created'], info_messages())
Пример #25
0
    def test_toc_depth_config(self, browser):
        book = create(Builder('book').titled('The Book'))
        chapter = create(Builder('chapter')
                         .titled('First Chapter')
                         .within(book))
        subchapter = create(Builder('chapter')
                            .titled('The SubChapter')
                            .within(chapter))
        create(Builder('chapter')
               .titled('The SubSubChapter')
               .within(subchapter))

        browser.login().visit(book)

        # view shows all subchapters by default
        self.assertEquals(
            ['The Book', '1 First Chapter',
                '1.1 The SubChapter', '1.1.1 The SubSubChapter'],
            [e.text for e in browser.css('#content-core .navTreeItem a')])

        # limit depth to 1 subchapter
        browser.open(book, view='edit')
        browser.fill({'Table of contents depth': '1'}).submit()

        self.assertEquals(
            ['The Book', '1 First Chapter'],
            [e.text for e in browser.css('#content-core .navTreeItem a')])

        # limit depth to 2 subchapter
        browser.open(book, view='edit')
        browser.fill({'Table of contents depth': '2'}).submit()

        self.assertEquals(
            ['The Book', '1 First Chapter', '1.1 The SubChapter'],
            [e.text for e in browser.css('#content-core .navTreeItem a')])

        # empty depth means no limit
        browser.open(book, view='edit')
        browser.fill({'Table of contents depth': ''}).submit()

        self.assertEquals(
            ['The Book', '1 First Chapter',
                '1.1 The SubChapter', '1.1.1 The SubSubChapter'],
            [e.text for e in browser.css('#content-core .navTreeItem a')])
Пример #26
0
def select_valid_payment_processor():
    assert_step(PAYMENT_PROCESSOR)
    # XXX: "Gegen Rechnung" should be translated to english
    browser.fill({'Gegen Rechnung': 'ftw.shop.InvoicePaymentProcessor'})
    import checkout
    return checkout
Пример #27
0
 def test_cookies(self, browser):
     browser.open(view='login_form')
     browser.fill({'Login Name': TEST_USER_NAME,
                   'Password': TEST_USER_PASSWORD}).submit()
     self.assertDictContainsSubset(AC_COOKIE_INFO,
                                   browser.cookies.get('__ac', None))