~danci-emanuel/mailman/mm_3.0b2

« back to all changes in this revision

Viewing changes to src/mailman/runners/tests/test_nntp.py

  • Committer: Barry Warsaw
  • Date: 2012-07-26 04:22:19 UTC
  • mfrom: (7149.2.19 bug-971013)
  • Revision ID: barry@list.org-20120726042219-o4asb3r7f6hil65t
 * The policy for archiving has now been collapsed into a single enum, called
   ArchivePolicy.  This describes the three states of never archive, archive
   privately, and archive_publicly. (LP: #967238)

Database
--------
 * Schema migrations (LP: #971013)
   - include_list_post_header -> allow_list_posts
   - news_prefix_subject_too  -> nntp_prefix_subject_too
   - news_moderation          -> newsgroup_moderation
   - archive and archive_private have been collapsed into archive_policy.
   - nntp_host has been removed.
 * The PostgreSQL port of the schema accidentally added a moderation_callback
   column to the mailinglist table.  Since this is unused in Mailman, it was
   simply commented out of the base schema for PostgreSQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
from mailman.app.lifecycle import create_list
35
35
from mailman.config import config
36
 
from mailman.interfaces.nntp import NewsModeration
 
36
from mailman.interfaces.nntp import NewsgroupModeration
37
37
from mailman.runners import nntp
38
38
from mailman.testing.helpers import (
39
39
    LogFileMark,
67
67
        # Approved header, which NNTP software uses to forward to the
68
68
        # newsgroup.  The message would not have gotten to the mailing list if
69
69
        # it wasn't already approved.
70
 
        self._mlist.news_moderation = NewsModeration.moderated
 
70
        self._mlist.newsgroup_moderation = NewsgroupModeration.moderated
71
71
        nntp.prepare_message(self._mlist, self._msg, {})
72
72
        self.assertEqual(self._msg['approved'], 'test@example.com')
73
73
 
76
76
        # message will get an Approved header, which NNTP software uses to
77
77
        # forward to the newsgroup.  The message would not have gotten to the
78
78
        # mailing list if it wasn't already approved.
79
 
        self._mlist.news_moderation = NewsModeration.open_moderated
 
79
        self._mlist.newsgroup_moderation = NewsgroupModeration.open_moderated
80
80
        nntp.prepare_message(self._mlist, self._msg, {})
81
81
        self.assertEqual(self._msg['approved'], 'test@example.com')
82
82
 
83
83
    def test_moderation_removes_previous_approved_header(self):
84
84
        # Any existing Approved header is removed from moderated messages.
85
85
        self._msg['Approved'] = 'a bogus approval'
86
 
        self._mlist.news_moderation = NewsModeration.moderated
 
86
        self._mlist.newsgroup_moderation = NewsgroupModeration.moderated
87
87
        nntp.prepare_message(self._mlist, self._msg, {})
88
88
        headers = self._msg.get_all('approved')
89
89
        self.assertEqual(len(headers), 1)
92
92
    def test_open_moderation_removes_previous_approved_header(self):
93
93
        # Any existing Approved header is removed from moderated messages.
94
94
        self._msg['Approved'] = 'a bogus approval'
95
 
        self._mlist.news_moderation = NewsModeration.open_moderated
 
95
        self._mlist.newsgroup_moderation = NewsgroupModeration.open_moderated
96
96
        nntp.prepare_message(self._mlist, self._msg, {})
97
97
        headers = self._msg.get_all('approved')
98
98
        self.assertEqual(len(headers), 1)
102
102
        # The cook-headers handler adds the original and/or stripped (of the
103
103
        # prefix) subject to the metadata.  Assume that handler's been run;
104
104
        # check the Subject header.
105
 
        self._mlist.news_prefix_subject_too = False
 
105
        self._mlist.nntp_prefix_subject_too = False
106
106
        del self._msg['subject']
107
107
        self._msg['subject'] = 'Re: Your test'
108
108
        msgdata = dict(stripped_subject='Your test')
115
115
        # The cook-headers handler adds the original and/or stripped (of the
116
116
        # prefix) subject to the metadata.  Assume that handler's been run;
117
117
        # check the Subject header.
118
 
        self._mlist.news_prefix_subject_too = False
 
118
        self._mlist.nntp_prefix_subject_too = False
119
119
        del self._msg['subject']
120
120
        self._msg['subject'] = 'Re: Your test'
121
121
        msgdata = dict(original_subject='Your test')
128
128
        # The cook-headers handler adds the original and/or stripped (of the
129
129
        # prefix) subject to the metadata.  Assume that handler's been run;
130
130
        # check the Subject header.
131
 
        self._mlist.news_prefix_subject_too = True
 
131
        self._mlist.nntp_prefix_subject_too = True
132
132
        del self._msg['subject']
133
133
        self._msg['subject'] = 'Re: Your test'
134
134
        msgdata = dict(stripped_subject='Your test')
141
141
        # The cook-headers handler adds the original and/or stripped (of the
142
142
        # prefix) subject to the metadata.  Assume that handler's been run;
143
143
        # check the Subject header.
144
 
        self._mlist.news_prefix_subject_too = True
 
144
        self._mlist.nntp_prefix_subject_too = True
145
145
        del self._msg['subject']
146
146
        self._msg['subject'] = 'Re: Your test'
147
147
        msgdata = dict(original_subject='Your test')