112
141
archived = message_from_file(fp)
113
142
self.assertEqual(archived['message-id'], '<first>')
144
@archiver('dummy', enable=True)
115
145
def test_archive_runner_with_dated_message(self):
117
self._msg['Date'] = 'Sat, 11 Mar 2011 03:19:38 -0500'
118
self._archiveq.enqueue(
119
self._msg, {}, listname=self._mlist.fqdn_listname)
121
# There should now be a copy of the message in the file system.
122
filename = os.path.join(
123
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
124
with open(filename) as fp:
125
archived = message_from_file(fp)
126
self.assertEqual(archived['message-id'], '<first>')
146
# Date headers don't throw off the archiver runner.
147
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
148
self._archiveq.enqueue(
150
listname=self._mlist.fqdn_listname,
153
# There should now be a copy of the message in the file system.
154
filename = os.path.join(
155
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
156
with open(filename) as fp:
157
archived = message_from_file(fp)
158
self.assertEqual(archived['message-id'], '<first>')
159
self.assertEqual(archived['date'], 'Mon, 01 Aug 2005 07:49:23 +0000')
161
@archiver('dummy', enable=True, clobber='never')
162
def test_clobber_date_never(self):
163
# Even if the Date header is insanely off from the received time of
164
# the message, if clobber_date is 'never', the header is not clobbered.
165
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
166
self._archiveq.enqueue(
168
listname=self._mlist.fqdn_listname,
171
# There should now be a copy of the message in the file system.
172
filename = os.path.join(
173
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
174
with open(filename) as fp:
175
archived = message_from_file(fp)
176
self.assertEqual(archived['message-id'], '<first>')
177
self.assertEqual(archived['date'], 'Mon, 01 Aug 2005 07:49:23 +0000')
179
@archiver('dummy', enable=True)
180
def test_clobber_dateless(self):
181
# A message with no Date header will always get clobbered.
182
self.assertEqual(self._msg['date'], None)
183
# Now, before enqueuing the message (well, really, calling 'now()'
184
# again), fast forward a few days.
185
self._archiveq.enqueue(
187
listname=self._mlist.fqdn_listname,
188
received_time=now(strip_tzinfo=False))
190
# There should now be a copy of the message in the file system.
191
filename = os.path.join(
192
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
193
with open(filename) as fp:
194
archived = message_from_file(fp)
195
self.assertEqual(archived['message-id'], '<first>')
196
self.assertEqual(archived['date'], 'Mon, 01 Aug 2005 07:49:23 +0000')
198
@archiver('dummy', enable=True, clobber='always')
199
def test_clobber_date_always(self):
200
# The date always gets clobbered with the current received time.
201
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
202
# Now, before enqueuing the message (well, really, calling 'now()'
203
# again as will happen in the runner), fast forward a few days.
204
self._archiveq.enqueue(
206
listname=self._mlist.fqdn_listname)
207
factory.fast_forward(days=4)
209
# There should now be a copy of the message in the file system.
210
filename = os.path.join(
211
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
212
with open(filename) as fp:
213
archived = message_from_file(fp)
214
self.assertEqual(archived['message-id'], '<first>')
215
self.assertEqual(archived['date'], 'Fri, 05 Aug 2005 07:49:23 +0000')
216
self.assertEqual(archived['x-original-date'],
217
'Mon, 01 Aug 2005 07:49:23 +0000')
219
@archiver('dummy', enable=True, clobber='maybe', skew='1d')
220
def test_clobber_date_maybe_when_insane(self):
221
# The date is clobbered if it's farther off from now than its skew
223
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
224
# Now, before enqueuing the message (well, really, calling 'now()'
225
# again as will happen in the runner), fast forward a few days.
226
self._archiveq.enqueue(
228
listname=self._mlist.fqdn_listname)
229
factory.fast_forward(days=4)
231
# There should now be a copy of the message in the file system.
232
filename = os.path.join(
233
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
234
with open(filename) as fp:
235
archived = message_from_file(fp)
236
self.assertEqual(archived['message-id'], '<first>')
237
self.assertEqual(archived['date'], 'Fri, 05 Aug 2005 07:49:23 +0000')
238
self.assertEqual(archived['x-original-date'],
239
'Mon, 01 Aug 2005 07:49:23 +0000')
241
@archiver('dummy', enable=True, clobber='maybe', skew='10d')
242
def test_clobber_date_maybe_when_sane(self):
243
# The date is not clobbered if it's nearer to now than its skew
245
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
246
# Now, before enqueuing the message (well, really, calling 'now()'
247
# again as will happen in the runner), fast forward a few days.
248
self._archiveq.enqueue(
250
listname=self._mlist.fqdn_listname)
251
factory.fast_forward(days=4)
253
# There should now be a copy of the message in the file system.
254
filename = os.path.join(
255
config.MESSAGES_DIR, '4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB')
256
with open(filename) as fp:
257
archived = message_from_file(fp)
258
self.assertEqual(archived['message-id'], '<first>')
259
self.assertEqual(archived['date'], 'Mon, 01 Aug 2005 07:49:23 +0000')
260
self.assertEqual(archived['x-original-date'], None)