~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Curtis Hovey
  • Date: 2012-01-30 20:57:08 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: curtis.hovey@canonical.com-20120130205708-1sxt295z6nvbsmfg
Added display_type == 'headers-only' support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
                    if k in parameters['headers'])
91
91
                message['headers'] = headers
92
92
            max_body = parameters.get('max_body_length')
93
 
            if max_body is not None:
 
93
            if display_type == 'headers-only':
 
94
                del message['body']
 
95
            elif max_body is not None:
94
96
                message['body'] = message['body'][:max_body]
95
97
            new_messages.append(message)
96
98
        messages = new_messages
429
431
            ]}):
430
432
            with ExpectedException(UnsupportedDisplayType, ''):
431
433
                client.get_messages('baz', display_type='unknown')
 
434
 
 
435
    def test_display_type_headers_only(self):
 
436
        client = GrackleClient('localhost', 8445)
 
437
        with ForkedFakeService.from_client(client,
 
438
            {'baz': [
 
439
                {'message_id': 'foo',
 
440
                 'headers': {'From': 'me', 'To': 'you'},
 
441
                 'body': 'abcdefghi'}
 
442
            ]}):
 
443
            response = client.get_messages('baz', display_type='headers-only')
 
444
        first_message = response['messages'][0]
 
445
        self.assertEqual('foo', first_message['message_id'])
 
446
        self.assertEqual({'From': 'me', 'To': 'you'}, first_message['headers'])
 
447
        self.assertNotIn('body', first_message)