108
107
def assertMessages(self, expected_ids, messages):
109
108
expected_msgids = [
110
109
'<message%d@example.com>' % id for id in expected_ids]
111
actual_msgids = [msg['message-id'] for msg in messages]
110
actual_msgids = [msg['headers']['message-id'] for msg in messages]
112
111
self.assertEqual(expected_msgids, actual_msgids)
114
113
def makeMessages(self, conn, archive, count):
144
143
pmsg['content'] = expected_content
145
144
self.assertEqual(
147
['date', 'from', 'subject', 'message-id', 'content'],
147
headers=['date', 'from', 'subject', 'message-id'],
151
151
def test_limit(self):
205
205
self.assertMessages([5], messages)
208
class TestMessageFormatters(unittest.TestCase):
208
class TestMessageFormatter(unittest.TestCase):
210
210
def test_all(self):
211
211
parsed = _parse_message(TEST_MESSAGE)[1]
212
212
parsed['content'] = TEST_MESSAGE
213
want, func = FORMATS['all'](['date', 'from', 'subject', 'message-id'])
215
['content', 'date', 'from', 'message-id', 'subject'],
217
formatted = func(parsed)
213
formatted = _format_message(
215
headers=['date', 'from', 'subject', 'message-id'],
219
'date': '2000-01-01T11:02:34+11:00',
220
'from': 'sysadmin@example.com',
221
'message-id': '<aaaaaaaaaaaaa@example.com>',
222
'subject': 'Everything is broken',
219
'date': '2000-01-01T11:02:34+11:00',
220
'from': 'sysadmin@example.com',
221
'message-id': '<aaaaaaaaaaaaa@example.com>',
222
'subject': 'Everything is broken',
223
224
'content': TEST_MESSAGE,
225
226
self.assertEqual(expected, formatted)