18
18
"""Test bounce model objects."""
20
from __future__ import absolute_import, unicode_literals
20
from __future__ import absolute_import, print_function, unicode_literals
22
22
__metaclass__ = type
30
30
from zope.component import getUtility
32
32
from mailman.app.lifecycle import create_list
33
from mailman.config import config
33
from mailman.database.transaction import transaction
34
34
from mailman.interfaces.bounce import BounceContext, IBounceProcessor
35
35
from mailman.testing.helpers import (
36
36
specialized_message_from_string as message_from_string)
54
54
def test_events_iterator(self):
55
self._processor.register(self._mlist, 'anne@example.com', self._msg)
56
self._processor.register(
57
self._mlist, 'anne@example.com', self._msg)
57
58
events = list(self._processor.events)
58
59
self.assertEqual(len(events), 1)
75
76
self.assertEqual(event.processed, False)
77
78
def test_unprocessed_events_iterator(self):
78
self._processor.register(self._mlist, 'anne@example.com', self._msg)
79
self._processor.register(self._mlist, 'bart@example.com', self._msg)
80
self._processor.register(
81
self._mlist, 'anne@example.com', self._msg)
82
self._processor.register(
83
self._mlist, 'bart@example.com', self._msg)
81
84
events = list(self._processor.events)
82
85
self.assertEqual(len(events), 2)
83
86
unprocessed = list(self._processor.unprocessed)
84
87
# The unprocessed list will be exactly the same right now.
85
88
self.assertEqual(len(unprocessed), 2)
86
89
# Process one of the events.
87
events[0].processed = True
91
events[0].processed = True
89
92
# Now there will be only one unprocessed event.
90
93
unprocessed = list(self._processor.unprocessed)
91
94
self.assertEqual(len(unprocessed), 1)
92
95
# Process the other event.
93
events[1].processed = True
97
events[1].processed = True
95
98
# Now there will be no unprocessed events.
96
99
unprocessed = list(self._processor.unprocessed)
97
100
self.assertEqual(len(unprocessed), 0)