Beispiel #1
0
 def test_decorate_footer_with_archive_url(self):
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${testarchiver_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///myfooter.txt'
     self._mlist.preferred_language = 'en'
     decorate.process(self._mlist, self._msg, {})
     self.assertIn('http://example.com/link_to_message',
                   self._msg.as_string())
Beispiel #2
0
 def test_decorate_footer_with_archive_url(self):
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${testarchiver_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///myfooter.txt'
     self._mlist.preferred_language = 'en'
     decorate.process(self._mlist, self._msg, {})
     self.assertIn('http://example.com/link_to_message',
                   self._msg.as_string())
Beispiel #3
0
 def test_list_id_allowed_in_template_uri(self):
     # Issue #196 - allow the list_id in the template uri expansion.
     list_dir = os.path.join(config.TEMPLATE_DIR, 'lists',
                             'ant.example.com', 'en')
     os.makedirs(list_dir)
     footer_path = os.path.join(list_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${testarchiver_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///${list_id}/myfooter.txt'
     self._mlist.preferred_language = 'en'
     decorate.process(self._mlist, self._msg, {})
     self.assertIn('http://example.com/link_to_message',
                   self._msg.as_string())
Beispiel #4
0
 def test_list_id_allowed_in_template_uri(self):
     # Issue #196 - allow the list_id in the template uri expansion.
     list_dir = os.path.join(
         config.TEMPLATE_DIR, 'lists', 'ant.example.com', 'en')
     os.makedirs(list_dir)
     footer_path = os.path.join(list_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${testarchiver_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///${list_id}/myfooter.txt'
     self._mlist.preferred_language = 'en'
     decorate.process(self._mlist, self._msg, {})
     self.assertIn('http://example.com/link_to_message',
                   self._msg.as_string())
Beispiel #5
0
 def test_broken_permalink(self):
     # GL issue #208 - IArchive messages raise exceptions, breaking the
     # rfc-2369 handler and shunting messages.
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${broken_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///myfooter.txt'
     self._mlist.preferred_language = 'en'
     mark = LogFileMark('mailman.archiver')
     decorate.process(self._mlist, self._msg, {})
     log_messages = mark.read()
     self.assertNotIn('http:', self._msg.as_string())
     self.assertIn('Exception in "broken" archiver', log_messages)
     self.assertIn('RuntimeError: Cannot get permalink', log_messages)
 def test_decorate_user_name_or_address_as_address(self):
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('$user_name_or_address', file=fp)
     getUtility(ITemplateManager).set('list:member:regular:footer', None,
                                      'mailman:///myfooter.txt')
     self._mlist.preferred_language = 'en'
     user = getUtility(IUserManager).make_user('*****@*****.**')
     member = Member(MemberRole.member, self._mlist.list_id, user)
     member.preferences = Preferences()
     member.preferences.preferred_language = 'en'
     msgdata = dict(member=member)
     decorate.process(self._mlist, self._msg, msgdata)
     self.assertIn('*****@*****.**', self._msg.as_string())
Beispiel #7
0
 def test_broken_permalink(self):
     # GL issue #208 - IArchive messages raise exceptions, breaking the
     # rfc-2369 handler and shunting messages.
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${broken_url}', file=fp)
     self._mlist.footer_uri = 'mailman:///myfooter.txt'
     self._mlist.preferred_language = 'en'
     mark = LogFileMark('mailman.archiver')
     decorate.process(self._mlist, self._msg, {})
     log_messages = mark.read()
     self.assertNotIn('http:', self._msg.as_string())
     self.assertIn('Exception in "broken" archiver', log_messages)
     self.assertIn('RuntimeError: Cannot get permalink', log_messages)
 def test_list_id_and_language_code_allowed_in_template_uri(self):
     # Issue #196 - allow the list_id in the template uri expansion.
     list_dir = os.path.join(config.TEMPLATE_DIR, 'lists',
                             'ant.example.com', 'it')
     os.makedirs(list_dir)
     footer_path = os.path.join(list_dir, 'myfooter.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('${testarchiver_url}', file=fp)
     getUtility(ITemplateManager).set(
         'list:member:regular:footer', self._mlist.list_id,
         'mailman:///${list_id}/${language}/myfooter.txt')
     self._mlist.preferred_language = 'it'
     with configuration('language.it', charset='iso-8859-1'):
         # Default charset='utf-8' base64 encodes the message body.
         decorate.process(self._mlist, self._msg, {})
     self.assertIn('http://example.com/link_to_message',
                   self._msg.as_string())
 def test_decorate_header_footer_with_bad_character_mpm(self):
     site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
     os.makedirs(site_dir)
     footer_path = os.path.join(site_dir, 'myfooter.txt')
     header_path = os.path.join(site_dir, 'myheader.txt')
     with open(footer_path, 'w', encoding='utf-8') as fp:
         print('Foot\xe9r:', file=fp)
     with open(header_path, 'w', encoding='utf-8') as fp:
         print('Head\xe9r:', file=fp)
     getUtility(ITemplateManager).set('list:member:regular:footer', None,
                                      'mailman:///myfooter.txt')
     getUtility(ITemplateManager).set('list:member:regular:header', None,
                                      'mailman:///myheader.txt')
     self._mlist.preferred_language = 'en'
     decorate.process(self._mlist, self._mpm, {})
     self.assertIn('Head?r:', self._mpm.get_payload(0).as_string())
     self.assertIn('Foot?r:', self._mpm.get_payload(3).as_string())