~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Curtis Hovey
  • Date: 2012-03-16 15:01:18 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: curtis.hovey@canonical.com-20120316150118-jqk101q03432af8x
Use a real rfc822 message for mime testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    UnsupportedOrder,
25
25
    )
26
26
from grackle.store import (
 
27
    make_json_message,
27
28
    MemoryStore,
28
29
    )
29
30
 
51
52
                      attachment_type=None):
52
53
    message = MIMEMultipart()
53
54
    message.attach(MIMEText(body))
 
55
    if headers is None:
 
56
        headers = {}
 
57
    for key, value in headers.items():
 
58
        message[key] = value
54
59
    if attachment_type is not None:
55
60
        attachment = Message()
56
61
        attachment.set_payload('attactment data.')
57
62
        attachment['Content-Type'] = attachment_type
58
63
        attachment['Content-Disposition'] = 'attachment; filename="file.ext"'
59
64
        message.attach(attachment)
60
 
    return make_message(message_id, message.get_payload(), headers, hidden)
 
65
    return make_json_message(message_id, message.as_string())
61
66
 
62
67
 
63
68
class ForkedFakeService:
411
416
        self.assertEqual('foo', first_message['message_id'])
412
417
        self.assertEqual('me', first_message['headers']['From'])
413
418
        self.assertEqual('you', first_message['headers']['To'])
414
 
        self.assertEqual('abcdefghi', first_message['body'])
 
419
        self.assertEqual(archive['baz'][0]['body'], first_message['body'])
415
420
 
416
421
    def test_display_type_all(self):
417
422
        client = GrackleClient('localhost', 8447)
427
432
        self.assertEqual('foo', first_message['message_id'])
428
433
        self.assertEqual('me', first_message['headers']['From'])
429
434
        self.assertEqual('you', first_message['headers']['To'])
430
 
        self.assertEqual(
431
 
            'abcdefghi\n\nattactment data.', first_message['body'])
 
435
        self.assertEqual(archive['baz'][0]['body'], first_message['body'])
432
436
 
433
437
    def test_date_range(self):
434
438
        client = GrackleClient('localhost', 8448)