~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:25:49 UTC
  • Revision ID: curtis.hovey@canonical.com-20120316202549-2dqmxc2f8d9dr7k9
Raise an error when the archive already exists.

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 (
21
 
    GrackleClient,
 
20
from grackle.client import GrackleClient
 
21
from grackle.error import (
 
22
    ArchiveIdExists,
22
23
    UnparsableDateRange,
23
24
    UnsupportedDisplayType,
24
25
    UnsupportedOrder,
148
149
                self.send_response(httplib.CREATED)
149
150
                self.end_headers()
150
151
                self.wfile.close()
151
 
            except:
152
 
                self.send_error(httplib.BAD_REQUEST)
 
152
            except Exception, error:
 
153
                self.send_response(
 
154
                    httplib.BAD_REQUEST, error.__doc__)
153
155
        if len(parts) == 4:
154
156
            # This expected path is /archive/archive_id/message_id.
155
157
            try:
207
209
 
208
210
class TestPutArchive(TestCase):
209
211
 
210
 
    def test_put_message(self):
 
212
    def test_put_archive(self):
211
213
        client = GrackleClient('localhost', 8410)
212
214
        message_archives = {}
213
215
        with ForkedFakeService.from_client(client, message_archives):
215
217
            response = client.get_messages('arch1')
216
218
        self.assertEqual(0, len(response['messages']))
217
219
 
 
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
 
218
227
 
219
228
class TestPutMessage(TestCase):
220
229