~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 19:49:31 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: curtis.hovey@canonical.com-20120316194931-xngt1fdw9ewovwqn
Use PUT for creating messages.

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,
142
141
        if parts[1] != 'archive':
143
142
            # This is an unknonwn operation?
144
143
            return
145
 
        if len(parts) == 3:
146
 
            # This expected path is /archive/archive_id.
147
 
            try:
148
 
                self.server.store.put_archive(parts[2])
149
 
                self.send_response(httplib.CREATED)
150
 
                self.end_headers()
151
 
                self.wfile.close()
152
 
            except Exception, error:
153
 
                self.send_response(
154
 
                    httplib.BAD_REQUEST, error.__doc__)
155
144
        if len(parts) == 4:
156
145
            # This expected path is /archive/archive_id/message_id.
157
146
            try:
207
196
        self.logger.info(message)
208
197
 
209
198
 
210
 
class TestPutArchive(TestCase):
211
 
 
212
 
    def test_put_archive(self):
213
 
        client = GrackleClient('localhost', 8410)
214
 
        message_archives = {}
215
 
        with ForkedFakeService.from_client(client, message_archives):
216
 
            client.put_archive('arch1')
217
 
            response = client.get_messages('arch1')
218
 
        self.assertEqual(0, len(response['messages']))
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
 
 
227
 
 
228
199
class TestPutMessage(TestCase):
229
200
 
230
201
    def test_put_message(self):