def checkout_and_get_mail(self, *items):
     mailing = Mailing(self.portal)
     for item in items:
         checkout.visit_checkout_with_one_item_in_cart(item)
     checkout.goto(checkout.ORDER_REVIEW).finish()
     self.assertEquals(1, len(mailing.get_messages()),
                       'Notifying shop owner is disabled by default, therefore'
                       ' only one mail (to the customer) should be sent.')
     return email.message_from_string(mailing.pop())
Example #2
0
    def test_task_title_is_linked_to_resolve_notification_view(self, browser):
        self.login(self.dossier_responsible, browser)

        self.create_task_via_browser(browser)
        process_mail_queue()

        raw_mail = Mailing(self.portal).pop()
        link = '<p><a href=3D"http://nohost/plone/@@resolve_notification?notification=\n_id=3D1">Test Task</a></p>'
        self.assertIn(link, raw_mail.strip())
    def checkout_and_get_mail(self, *items):
        mailing = Mailing(self.portal)
        for item in items:
            checkout.visit_checkout_with_one_item_in_cart(item)
        checkout.goto(checkout.ORDER_REVIEW).finish()

        mails_by_recipient = mailing.get_messages_by_recipient()
        owner = 'Shop Owner <*****@*****.**>'
        self.assertIn(owner, mails_by_recipient,
                      'Expected a mail to the shop owner to be sent')
        return email.message_from_string(mails_by_recipient[owner][0])
Example #4
0
    def test_subject_is_title(self, browser):
        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(self.org_unit.id() + ':hugo.boss')

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

        mail = email.message_from_string(Mailing(self.portal).pop())

        self.assertEquals('GEVER Task: Test Task', mail.get('Subject'))
Example #5
0
    def test_from_and_to_addresses(self, browser):
        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(self.org_unit.id() + ':hugo.boss')
        browser.css('#form-buttons-save').first.click()

        mail = email.message_from_string(Mailing(self.portal).pop())
        self.assertEquals('*****@*****.**', mail.get('To'))
        self.assertEquals(
            'Test User <*****@*****.**>', get_header(mail, 'From'))
    def test_notification_summary_is_split_into_paragraphs(self, browser):
        self.login(self.dossier_responsible, browser)
        self.create_task_via_browser(browser)
        process_mail_queue()

        # Discard the first mail
        Mailing(self.portal).pop()

        # XXX - did not find a neater way to get the task quickly
        browser.open(Task.query.all()[-1], view='addcommentresponse')
        browser.fill({'Response': 'Multi\n\nline\ncomment'})
        browser.css('#form-buttons-save').first.click()
        process_mail_queue()

        mails = Mailing(self.portal).get_messages()
        self.assertEqual(len(mails), 1)
        raw_mail = mails[0]

        self.assertIn('<p>Multi</p>', raw_mail)
        self.assertIn('<p></p>', raw_mail)
        self.assertIn('<p>line</p>', raw_mail)
        self.assertIn('<p>comment</p>', raw_mail)
Example #7
0
    def test_mail_dispatcher_respects_dispatcher_roles_even_if_its_a_group(self, browser):
        """By default only the responsible should be notified by mail, when
        a task gets added.
        """

        inbox_group = self.org_unit.inbox_group
        inbox_group.users.append(self.hugo)
        inbox_group.users.append(self.franz)

        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(
            self.org_unit.id() + ':franz.michel')
        form.find_widget('Issuer').fill('inbox:client1')

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

        self.assertEquals(1, len(Mailing(self.portal).get_messages()))
        mail = email.message_from_string(Mailing(self.portal).pop())
        self.assertEquals(
            '*****@*****.**', get_header(mail, 'To'))
    def test_notification_add_task_summary_is_split_into_lines(self, browser):
        self.login(self.dossier_responsible, browser)
        self.create_task_via_browser(browser,
                                     description='Multi\nline\ncomment')
        process_mail_queue()

        mails = Mailing(self.portal).get_messages()
        self.assertEqual(len(mails), 1)
        raw_mail = mails[0]
        mail = raw_mail.decode("quopri")

        self.assertIn('<td>Multi<br />', mail)
        self.assertIn('line<br />', mail)
        self.assertIn('comment</td>', mail)
Example #9
0
    def test_notification_mailer_handle_empty_activity_description(self, browser):
        self.login(self.dossier_responsible, browser)
        self.create_task_via_browser(browser)
        process_mail_queue()

        # Discard the first mail
        Mailing(self.portal).pop()

        # reassign task
        task = self.dossier.objectValues()[-1]
        data = {'form.widgets.transition': 'task-transition-reassign'}
        browser.open(task, data, view='assign-task')
        responsible = 'fa:{}'.format(self.secretariat_user.getId())
        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill(responsible)
        browser.click_on('Assign')
        process_mail_queue()

        mails = Mailing(self.portal).get_messages()
        mails.sort(key=lambda data: email.message_from_string(data).get('To'))

        self.assertEqual(len(mails), 1)
        raw_mail = mails[0]
        self.assertIn('Reassigned from', raw_mail)
Example #10
0
    def test_notification_mailer_handle_empty_activity_description(
            self, browser):
        self.login(self.dossier_responsible, browser)
        self.create_task_via_browser(browser)
        process_mail_queue()

        # Discard the first mail
        Mailing(self.portal).pop()

        # reassign task
        task = self.dossier.objectValues()[-1]
        data = {'form.widgets.transition': 'task-transition-reassign'}
        browser.open(task, data, view='assign-task')
        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill(self.secretariat_user)
        browser.click_on('Assign')
        process_mail_queue()

        mails = Mailing(self.portal).get_messages()
        mails.sort(key=lambda data: email.message_from_string(data).get('To'))

        self.assertEqual(len(mails), 1)
        raw_mail = mails[0]
        self.assertIn('Reassigned from', raw_mail)
Example #11
0
    def test_task_title_is_linked_to_resolve_notification_view(self, browser):
        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(self.org_unit.id() + ':hugo.boss')
        browser.css('#form-buttons-save').first.click()

        mail = email.message_from_string(Mailing(self.portal).pop())
        html_part = mail.get_payload()[0].as_string()

        link = '<p><a href=3D"http://example.com/@@resolve_notification' \
               '?notification_id=\n=3D1">Test Task</a></p>'

        self.assertIn(link, html_part)
Example #12
0
    def test_mail_contains_date_activity_summaries(self, browser):
        with freeze(datetime(2017, 10, 16, 0, 0, tzinfo=pytz.utc)):
            DigestMailer().send_digests()

        messages = [
            message_from_string(mail)
            for mail in Mailing(self.portal).get_messages()
        ]

        browser.open_html(str(messages[0].get_payload()[0]))

        self.assertEquals('Oct 16, 201= 7', browser.css('table p').text[0])
        self.assertEquals(['Daily Digest for B=C3=A4rfuss K=C3=A4thi'],
                          browser.css('h1').text)
        self.assertEquals(['Bitte =C3=84nderungen nachvollzie= hen'],
                          browser.css('h2 a').text)
Example #13
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.mails = Mailing(self.portal)
        self.mails.set_up()

        self.storage = IDownloadTokenStorage(self.portal)

        wftool = getToolByName(self.portal, 'portal_workflow')
        wftool.setChainForPortalTypes(('Folder',),
                                      ('plone_workflow',))
        transaction.commit()

        folder = create(Builder('folder').in_state('private'))
        self.file_ = create(Builder('file')
            .titled('\xc3\xa4 file')
            .with_dummy_content()
            .within(folder))
    def setUp(self):
        super(TestTaskReassignActivity, self).setUp()
        insert_notification_defaults(self.portal)
        Mailing(self.portal).set_up()

        self.dossier = create(Builder('dossier').titled(u'Dossier XY'))
        self.hugo = create(
            Builder('ogds_user').id('hugo.boss').assign_to_org_units(
                [self.org_unit]).having(firstname=u'Hugo',
                                        lastname=u'Boss',
                                        email='*****@*****.**'))

        create(
            Builder('ogds_user').id('peter.meier').assign_to_org_units(
                [self.org_unit]).having(firstname=u'Peter', lastname=u'Meier'))
        create(
            Builder('ogds_user').id('james.meier').assign_to_org_units(
                [self.org_unit]).having(firstname=u'James', lastname=u'Meier'))
Example #15
0
    def test_notification_mailer_handle_empty_activity_description(
            self, browser):
        self.login(self.dossier_responsible, browser)
        self.create_task_via_browser(browser)

        # reassign task
        task = self.dossier.objectValues()[-1]
        data = {'form.widgets.transition': 'task-transition-reassign'}
        browser.open(task, data, view='assign-task')
        responsible = 'fa:{}'.format(self.secretariat_user.getId())
        form = browser.find_form_by_field('Responsible')
        form.find_widget('Responsible').fill(responsible)
        browser.click_on('Assign')

        mails = Mailing(self.portal).get_messages()
        self.assertEqual(len(mails), 2)
        raw_mail = mails[-1]
        self.assertIn('Reassigned from', raw_mail)
    def setUp(self):
        super(TestDigestMail, self).setUp()
        Mailing(self.portal).set_up()

        self.resource = create(Builder('resource').oguid('fd:123'))
        activity = create(
            Builder('activity').having(
                title=u'Bitte \xc4nderungen nachvollziehen',
                created=pytz.UTC.localize(datetime(2017, 10, 15, 18, 24)),
                resource=self.resource))

        self.note1 = create(
            Builder('notification').having(activity=activity,
                                           is_digest=True,
                                           userid=self.regular_user.getId()))
        self.note2 = create(
            Builder('notification').having(
                activity=activity,
                is_digest=True,
                userid=self.dossier_responsible.getId()))
Example #17
0
    def setUp(self):
        super(TestEmailNotification, self).setUp()
        # setup mail
        Mailing(self.portal).set_up()

        self.hugo = create(Builder('ogds_user')
                           .assign_to_org_units([self.org_unit])
                           .having(userid='hugo.boss',
                                   firstname='Hugo',
                                   lastname='Boss',
                                   email='*****@*****.**'))

        self.franz = create(Builder('ogds_user')
               .assign_to_org_units([self.org_unit])
               .having(userid='franz.michel',
                       firstname='Franz',
                       lastname='Michel',
                       email='*****@*****.**'))

        create(Builder('watcher').having(actorid='hugo.boss'))

        self.dossier = create(Builder('dossier').titled(u'Dossier A'))

        insert_notification_defaults(self.portal)
 def get_mail(self):
     if Mailing(self.portal).has_messages():
         data = Mailing(self.portal).pop()
         return email.message_from_string(data)
 def tearDown(self):
     Mailing(self.layer['portal']).tear_down()
Example #20
0
 def test_subject_is_title(self, browser):
     self.login(self.dossier_responsible, browser)
     self.create_task_via_browser(browser)
     mail = email.message_from_string(Mailing(self.portal).pop())
     self.assertEquals('GEVER Task: Test Task', mail.get('Subject'))
 def tearDown(self):
     super(TestDigestMail, self).tearDown()
     Mailing(self.portal).tear_down()
Example #22
0
 def test_task_title_is_linked_to_resolve_notification_view(self, browser):
     self.login(self.dossier_responsible, browser)
     self.create_task_via_browser(browser)
     raw_mail = Mailing(self.portal).pop()
     link = '<p><a href=3D"http://nohost/plone/@@resolve_notification?notification_i=\nd=3D1">Test Task</a></p>'
     self.assertIn(link, raw_mail.strip())
Example #23
0
 def tearDown(self):
     super(IntegrationTestCase, self).tearDown()
     if 'activity' in self.features:
         Mailing(self.portal).tear_down()
Example #24
0
class TestStorage(TestCase):

    layer = FTW_DOWNLOADTOKEN_FUNCTIONAL_TESTING

    def setUp(self):
        self.portal = self.layer['portal']
        self.mails = Mailing(self.portal)
        self.mails.set_up()

        self.storage = IDownloadTokenStorage(self.portal)

        wftool = getToolByName(self.portal, 'portal_workflow')
        wftool.setChainForPortalTypes(('Folder',),
                                      ('plone_workflow',))
        transaction.commit()

        folder = create(Builder('folder').in_state('private'))
        self.file_ = create(Builder('file')
            .titled('\xc3\xa4 file')
            .with_dummy_content()
            .within(folder))

    def tearDown(self):
        Mailing(self.layer['portal']).tear_down()

    @browsing
    def test_send_mail_form(self, browser):
        browser.login().visit(self.file_, view='send-mail-form')
        browser.fill({'Recipients': '*****@*****.**'})
        browser.find('Send').click()

        self.assertEquals(1,
                          len(self.mails.get_messages()),
                          'Expect one message')

        self.assertEquals('{0}/view'.format(self.file_.absolute_url()),
                          browser.url)

    @browsing
    def test_send_mail_journalized(self, browser):
        eventtesting.clearEvents()
        browser.login().visit(self.file_, view='send-mail-form')
        browser.fill({'Recipients': '*****@*****.**',
                      'Comment': 'Test'})
        browser.find('Send').click()
        events = [e for e in eventtesting.getEvents()
                  if IJournalEntryEvent.providedBy(e)]
        self.assertEqual(1, len(events))
        self.assertIn(
            '*****@*****.**',
            self.file_.translate(events[0].action))
        self.assertEqual(u'Test', events[0].comment)

    @browsing
    def test_cancel_send_mail_form(self, browser):
        browser.login().visit(self.file_, view='send-mail-form')
        browser.find('Cancel').click()

        self.assertEquals(0,
                          len(self.mails.get_messages()),
                          'Expect one message')

        self.assertEquals('{0}/view'.format(self.file_.absolute_url()),
                          browser.url)

    @browsing
    def test_link_in_mail(self, browser):
        browser.login().visit(self.file_, view='send-mail-form')
        browser.fill({'Recipients': '*****@*****.**'})
        browser.find('Send').click()

        mail = self.mails.pop()
        url = get_link_from_email(mail)
        browser.logout().open(url)
        self.assertEquals('Test data', browser.contents)

        with self.assertRaises(Unauthorized):
            browser.visit(self.file_)

    @browsing
    def test_multiple_recipients(self, browser):
        browser.login().visit(self.file_, view='send-mail-form')
        browser.fill({'Recipients': '[email protected]\[email protected]'})
        browser.find('Send').click()

        self.assertEquals(2,
                          len(self.mails.get_messages()),
                          'Expect two messages')

        self.assertEquals(2,
                          len(self.storage.get_storage()),
                          'Expect two items')

    @browsing
    def test_send_mail_form_valid_email_addresses(self, browser):
        browser.login().visit(self.file_, view='send-mail-form')
        browser.fill({'Recipients': 'email@example\[email protected]'})
        browser.find('Send').click()

        statusmessages.error_messages()
        self.assertFalse(len(self.storage.get_storage()), 'Expect no tokens.')

        browser.fill({'Recipients': u'em\xe4il@example'})
        statusmessages.error_messages()
Example #25
0
 def tearDown(self):
     super(TestTaskReassignActivity, self).tearDown()
     Mailing(self.layer['portal']).tear_down()
Example #26
0
 def tearDown(self):
     super(TestSuccesssorHandling, self).tearDown()
     Mailing(self.layer['portal']).tear_down()
Example #27
0
 def tearDown(self):
     super(TestEmailNotification, self).tearDown()
     Mailing(self.layer['portal']).tear_down()