from __future__ import unicode_literals
import sys
+from collections import defaultdict
from datetime import datetime
from . import six
return {}
response = gen_parsed_response(text)
- parsed_response = {}
+ parsed_response = defaultdict(dict)
while True:
try:
msg_id = seq = _int_or_error(six.next(response),
else:
msg_data[word] = value
- parsed_response[msg_id] = msg_data
+ parsed_response[msg_id].update(msg_data)
return parsed_response
7: {'FLAGS': ('Baz', 'Sneeve'), 'SEQ': 7},
})
+ def test_same_message_appearing_multiple_times(self):
+ # This can occur when server sends unsolicited FETCH responses
+ # (e.g. RFC 4551)
+ self.assertEqual(parse_fetch_response(
+ ["2 (FLAGS (Foo Bar)) ",
+ "2 (MODSEQ 4)"]),
+ {2: {'FLAGS': ('Foo', 'Bar'), 'SEQ': 2, 'MODSEQ': 4}})
def test_literals(self):
self.assertEqual(parse_fetch_response([('1 (RFC822.TEXT {4}', 'body'),