Exemplo n.º 1
0
 def test_non_ascii_message(self):
     msg = Message()
     msg['From'] = '*****@*****.**'
     msg['To'] = '*****@*****.**'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
     mbox.add(msg.as_string())
     self._digestq.enqueue(
         msg,
         listname=self._mlist.fqdn_listname,
         digest_path=mbox_path,
         volume=1, digest_number=1)
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     self._runner.run()
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     # There are two messages in the virgin queue: the digest as plain-text
     # and as multipart.
     messages = get_queue_messages('virgin')
     self.assertEqual(len(messages), 2)
     self.assertEqual(
         sorted(item.msg.get_content_type() for item in messages),
         ['multipart/mixed', 'text/plain'])
     for item in messages:
         self.assertEqual(item.msg['subject'],
                          'Test Digest, Vol 1, Issue 1')
Exemplo n.º 2
0
 def test_only_decorate_output(self):
     # Ensure that decoration is not done on the archive, digest, or
     # usenet copy of the message.
     self.assertTrue(self._mlist.digests_enabled)
     # Set up NNTP.
     self._mlist.gateway_to_news = True
     self._mlist.linked_newsgroup = 'testing'
     self._mlist.nntp_host = 'news.example.com'
     # Process the email.
     process(self._mlist, self._msg, {},
             pipeline_name='default-posting-pipeline')
     for queue in ('archive', 'nntp'):
         items = get_queue_messages(queue, expected_count=1)
         payload = items[0].msg.get_payload()
         self.assertNotIn('Test mailing list', payload)
     self.assertEqual(len(digest_mbox(self._mlist)), 1)
     payload = digest_mbox(self._mlist)[0].get_payload()
     self.assertNotIn('Test mailing list', payload)
Exemplo n.º 3
0
 def test_only_decorate_output(self):
     # Ensure that decoration is not done on the archive, digest, or
     # usenet copy of the message.
     self.assertTrue(self._mlist.digests_enabled)
     # Set up NNTP.
     self._mlist.gateway_to_news = True
     self._mlist.linked_newsgroup = 'testing'
     self._mlist.nntp_host = 'news.example.com'
     # Process the email.
     process(self._mlist,
             self._msg, {},
             pipeline_name='default-posting-pipeline')
     for queue in ('archive', 'nntp'):
         items = get_queue_messages(queue, expected_count=1)
         payload = items[0].msg.get_payload()
         self.assertNotIn('Test mailing list', payload)
     self.assertEqual(len(digest_mbox(self._mlist)), 1)
     payload = digest_mbox(self._mlist)[0].get_payload()
     self.assertNotIn('Test mailing list', payload)
Exemplo n.º 4
0
 def test_non_ascii_message(self):
     msg = Message()
     msg['From'] = '*****@*****.**'
     msg['To'] = '*****@*****.**'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox.add(msg.as_string())
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     make_digest_messages(self._mlist, msg)
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     self._check_virgin_queue()
Exemplo n.º 5
0
 def test_non_ascii_message(self):
     # Subscribe some users receiving digests.
     anne = subscribe(self._mlist, 'Anne')
     anne.preferences.delivery_mode = DeliveryMode.mime_digests
     bart = subscribe(self._mlist, 'Bart')
     bart.preferences.delivery_mode = DeliveryMode.plaintext_digests
     msg = Message()
     msg['From'] = '*****@*****.**'
     msg['To'] = '*****@*****.**'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox.add(msg.as_string())
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     make_digest_messages(self._mlist, msg)
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     self._check_virgin_queue()
Exemplo n.º 6
0
 def test_non_ascii_message(self):
     # Subscribe some users receiving digests.
     anne = subscribe(self._mlist, 'Anne')
     anne.preferences.delivery_mode = DeliveryMode.mime_digests
     bart = subscribe(self._mlist, 'Bart')
     bart.preferences.delivery_mode = DeliveryMode.plaintext_digests
     msg = Message()
     msg['From'] = '*****@*****.**'
     msg['To'] = '*****@*****.**'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox.add(msg.as_string())
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     make_digest_messages(self._mlist, msg)
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     self._check_virgin_queue()