~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Curtis Hovey
  • Date: 2012-03-16 20:16:12 UTC
  • Revision ID: curtis.hovey@canonical.com-20120316201612-lr7b32umqgduaja6
Added a rudimentary put_archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from testtools import ExpectedException
19
19
 
20
 
from grackle.client import GrackleClient
21
 
from grackle.error import (
22
 
    ArchiveIdExists,
 
20
from grackle.client import (
 
21
    GrackleClient,
23
22
    UnparsableDateRange,
24
23
    UnsupportedDisplayType,
25
24
    UnsupportedOrder,
149
148
                self.send_response(httplib.CREATED)
150
149
                self.end_headers()
151
150
                self.wfile.close()
152
 
            except Exception, error:
153
 
                self.send_response(
154
 
                    httplib.BAD_REQUEST, error.__doc__)
 
151
            except:
 
152
                self.send_error(httplib.BAD_REQUEST)
155
153
        if len(parts) == 4:
156
154
            # This expected path is /archive/archive_id/message_id.
157
155
            try:
209
207
 
210
208
class TestPutArchive(TestCase):
211
209
 
212
 
    def test_put_archive(self):
 
210
    def test_put_message(self):
213
211
        client = GrackleClient('localhost', 8410)
214
212
        message_archives = {}
215
213
        with ForkedFakeService.from_client(client, message_archives):
217
215
            response = client.get_messages('arch1')
218
216
        self.assertEqual(0, len(response['messages']))
219
217
 
220
 
    def test_put_archive_existing_archive(self):
221
 
        client = GrackleClient('localhost', 8411)
222
 
        message_archives = {'arch1': []}
223
 
        with ForkedFakeService.from_client(client, message_archives):
224
 
            with ExpectedException(ArchiveIdExists, ''):
225
 
                client.put_archive('arch1')
226
 
 
227
218
 
228
219
class TestPutMessage(TestCase):
229
220