~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Aaron Bentley
  • Date: 2012-01-11 13:31:08 UTC
  • Revision ID: aaron@canonical.com-20120111133108-9ijvfo7quc49wmm8
Retrieve messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import httplib
6
6
import os
7
7
from signal import SIGKILL
 
8
import simplejson
8
9
from StringIO import StringIO
9
10
from unittest import TestCase
 
11
from urlparse import urlparse
10
12
 
11
13
from testtools import ExpectedException
12
14
 
55
57
        else:
56
58
            self.send_error(httplib.BAD_REQUEST)
57
59
 
 
60
    def do_GET(self):
 
61
        scheme, netloc, path, params, query, fragments = urlparse(self.path)
 
62
        archive = os.path.split(path)[1]
 
63
        self.send_response(httplib.OK)
 
64
        self.end_headers()
 
65
        print "path: %s" % self.path
 
66
        self.wfile.write(simplejson.dumps(self.server.messages[archive]))
 
67
 
58
68
 
59
69
def fake_grackle_service(client, messages=None):
60
70
    if messages is None:
81
91
            {'baz':
82
92
            [{'message-id': 'foo'},
83
93
             {'message-id': 'bar'}]}):
84
 
            response = client.get_messages('baz')
85
 
        self.assertEqual(['bar', 'foo'], sorted(response.keys()))
 
94
            response = client.get_messages('baz', message_ids=['a'])
 
95
        self.assertEqual(['bar', 'foo'], sorted(m['message-id'] for m in
 
96
            response))