124
124
part.get_payload() for part in message['body']
125
125
if part.get_content_type() == 'text/plain']
126
message['body'] = '\n'.join(text_parts)
127
elif max_body is not None:
126
message['body'] = '\n\n'.join(text_parts)
127
elif (display_type == 'all'
128
and 'body' in message
129
and isinstance(message['body'], list)):
130
parts = [str(part.get_payload()) for part in message['body']]
131
message['body'] = '\n\n'.join(parts)
132
if max_body is not None and display_type != 'headers-only':
128
133
message['body'] = message['body'][:max_body]
130
# display_type == 'all'
132
134
new_messages.append(message)
133
135
messages = new_messages
134
136
limit = parameters.get('limit', 100)
499
501
self.assertEqual('foo', first_message['message_id'])
500
502
self.assertEqual('me', first_message['headers']['From'])
501
503
self.assertEqual('you', first_message['headers']['To'])
502
self.assertEqual(first_message['body'], 'abcdefghi')
504
self.assertEqual('abcdefghi', first_message['body'])
506
def test_display_type_all(self):
507
client = GrackleClient('localhost', 8447)
508
with ForkedFakeService.from_client(client,
511
'abcdefghi', message_id='foo',
512
headers={'From': 'me', 'To': 'you'},
513
attachment_type='text/x-diff')
515
response = client.get_messages('baz', display_type='all')
516
first_message = response['messages'][0]
517
self.assertEqual('foo', first_message['message_id'])
518
self.assertEqual('me', first_message['headers']['From'])
519
self.assertEqual('you', first_message['headers']['To'])
521
'abcdefghi\n\nattactment data.', first_message['body'])