~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:31:29 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: curtis.hovey@canonical.com-20120130203129-mr4jjkjm401g3vdq
Added SUPPORTED_DISPLAY_TYPES.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from grackle.client import (
19
19
    GrackleClient,
 
20
    UnsupportedDisplayType,
20
21
    UnsupportedOrder,
21
22
    )
22
23
 
70
71
                    messages.extend(thread)
71
72
            else:
72
73
                messages.sort(key=lambda m: m[order])
 
74
        display_type = parameters.get('display_type', 'all')
 
75
        if display_type not in SUPPORTED_DISPLAY_TYPES:
 
76
            raise UnsupportedDisplayType
73
77
        new_messages = []
74
78
        for message in messages:
75
79
            if (not parameters['include_hidden']
182
186
        os.kill(self.pid, SIGKILL)
183
187
 
184
188
 
 
189
SUPPORTED_DISPLAY_TYPES = set(['all', 'text-only', 'headers-only'])
 
190
 
 
191
 
185
192
SUPPORTED_ORDERS = set(
186
193
    ['date', 'author', 'subject', 'thread_newest', 'thread_oldest',
187
194
     'thread_subject'])
413
420
            self.assertMessageIDs(['bar', 'foo'], response['messages'])
414
421
            response = client.get_messages('baz', include_hidden=False)
415
422
            self.assertMessageIDs(['bar'], response['messages'])
 
423
 
 
424
    def test_display_type_unknown_value(self):
 
425
        client = GrackleClient('localhost', 8444)
 
426
        with ForkedFakeService.from_client(client,
 
427
            {'baz': [
 
428
                {'message_id': 'foo', 'body': u'abcdefghi'}
 
429
            ]}):
 
430
            with ExpectedException(UnsupportedDisplayType, ''):
 
431
                client.get_messages('baz', display_type='unknown')