コード例 #1
0
 def afterSetUp(self):
     addNyForum(
                     self.portal,
                     id='forum_id',
                     title='myforum',
                     categories=['Test category', 'Test category 2'],
                     description='Description 1',
                     file_max_size='15',
                     )
     forum = self.portal.forum_id
     myfile = StringIO('some test data')
     myfile.filename = 'the_file.txt'
     addNyForumTopic(forum,
                     id='topic_id',
                     title='topic title',
                     category='Test category',
                     description='Test Description',
                     attachment=myfile,
                     sort_reverse=True,
                     )
     topic = forum.topic_id
     addNyForumMessage(topic,
                     id='message_id',
                     title='Message title',
                     description='Message Description',
                     attachment=myfile,
                     )
     message = topic.message_id
     message.replyMessage(title='Reply to message_id',
                     description='Reply message description',
                     attachment=myfile,
                     )
     transaction.commit()
コード例 #2
0
    def test_notify_new_message(self):
        addNyForumTopic(self.portal['tforum'],
                        id='newtopic', title='My New Topic')
        notif_tool = self.portal.getNotificationTool()
        self._notifications[:] = []
        addNyForumMessage(self.portal['tforum']['newtopic'],
                          title='My New Message')

        # check instant notifications
        self.assertEqual(len(self._notifications), 1,
                         'No instant notification was sent')
        self.assertTrue('Change notification' in self._notifications[0][2])
        self.assertTrue('My New Message' in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications
        notif_tool._send_newsletter('weekly',
                                    date.today() - timedelta(days=4),
                                    date.today() + timedelta(days=3))

        self.assertEqual(len(self._notifications), 1,
                         'No weekly notification was sent')
        self.assertTrue('weekly digest' in self._notifications[0][2])
        self.assertTrue('My New Topic' in self._notifications[0][3])
        self.assertTrue('My New Message' in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications in a different week
        notif_tool._send_newsletter('weekly',
                                    date.today() + timedelta(days=3),
                                    date.today() + timedelta(days=10))
        self.assertEqual(len(self._notifications), 0,
                         'Extra weekly notification was sent')
コード例 #3
0
    def test_notify_new_message(self):
        addNyForumTopic(self.portal['tforum'],
                        id='newtopic',
                        title='My New Topic')
        notif_tool = self.portal.getNotificationTool()
        self._notifications[:] = []
        addNyForumMessage(self.portal['tforum']['newtopic'],
                          title='My New Message')

        # check instant notifications
        self.assertEqual(len(self._notifications), 1,
                         'No instant notification was sent')
        self.assertTrue('Change notification' in self._notifications[0][2])
        self.assertTrue('My New Message' in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications
        notif_tool._send_newsletter('weekly',
                                    date.today() - timedelta(days=4),
                                    date.today() + timedelta(days=3))

        self.assertEqual(len(self._notifications), 1,
                         'No weekly notification was sent')
        self.assertTrue('weekly digest' in self._notifications[0][2])
        self.assertTrue('My New Topic' in self._notifications[0][3])
        self.assertTrue('My New Message' in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications in a different week
        notif_tool._send_newsletter('weekly',
                                    date.today() + timedelta(days=3),
                                    date.today() + timedelta(days=10))
        self.assertEqual(len(self._notifications), 0,
                         'Extra weekly notification was sent')
コード例 #4
0
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, self._notifications)

        addNyForum(self.portal, id="tforum", title="My Forum")
        tforum = self.portal["tforum"]
        addNyForumTopic(tforum, id="ttopic", title="My Topic")
        addNyForumMessage(tforum["ttopic"], id="tmessage", title="My Message")
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config["enable_instant"] = True
        notif_tool.config["enable_weekly"] = True
        notif_tool.add_account_subscription("contributor", "tforum", "instant", "en")
        notif_tool.add_account_subscription("contributor", "tforum", "weekly", "en")
        transaction.commit()
コード例 #5
0
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, self._notifications)

        addNyForum(self.portal, id='tforum', title='My Forum')
        tforum = self.portal['tforum']
        addNyForumTopic(tforum, id='ttopic', title='My Topic')
        addNyForumMessage(tforum['ttopic'], id='tmessage', title='My Message')
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config['enable_instant'] = True
        notif_tool.config['enable_weekly'] = True
        notif_tool.add_account_subscription('contributor',
                                            'tforum', 'instant', 'en')
        notif_tool.add_account_subscription('contributor',
                                            'tforum', 'weekly', 'en')
        transaction.commit()
コード例 #6
0
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, self._notifications)

        addNyForum(self.portal, id='tforum', title='My Forum')
        tforum = self.portal['tforum']
        addNyForumTopic(tforum, id='ttopic', title='My Topic')
        addNyForumMessage(tforum['ttopic'], id='tmessage', title='My Message')
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config['enable_instant'] = True
        notif_tool.config['enable_weekly'] = True
        notif_tool.add_account_subscription('contributor', 'tforum', 'instant',
                                            'en')
        notif_tool.add_account_subscription('contributor', 'tforum', 'weekly',
                                            'en')
        transaction.commit()
コード例 #7
0
    def test_notify_new_topic(self):
        addNyForumTopic(self.portal["tforum"], id="tt2", title="My New Topic")
        notif_tool = self.portal.getNotificationTool()

        # check instant notifications
        self.assertEqual(len(self._notifications), 1, "No instant notification was sent")
        self.assertTrue("Change notification" in self._notifications[0][2])
        self.assertTrue("My New Topic" in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications
        notif_tool._send_newsletter("weekly", date.today() - timedelta(days=4), date.today() + timedelta(days=3))

        self.assertEqual(len(self._notifications), 1, "No weekly notification was sent")
        self.assertTrue("weekly digest" in self._notifications[0][2])
        self.assertTrue("My New Topic" in self._notifications[0][3])
        self._notifications[:] = []

        # check weekly notifications in a different week
        notif_tool._send_newsletter("weekly", date.today() + timedelta(days=3), date.today() + timedelta(days=10))
        self.assertEqual(len(self._notifications), 0, "Extra weekly notification was sent")