~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_request.py

  • Committer: Max Bowsher
  • Date: 2011-01-11 11:26:48 UTC
  • mto: This revision was merged to the branch mainline in revision 5589.
  • Revision ID: maxb@f2s.com-20110111112648-3lleuo22utyaunfw
Add a consistent header comment to tools/packaging/*.sh

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        raise errors.NoSuchFile('xyzzy')
42
42
 
43
43
 
44
 
class DoUnexpectedErrorRequest(request.SmartServerRequest):
45
 
    """A request that encounters a generic error in self.do()"""
46
 
 
47
 
    def do(self):
48
 
        dict()[1]
49
 
 
50
 
 
51
44
class ChunkErrorRequest(request.SmartServerRequest):
52
45
    """A request that raises an error from self.do_chunk()."""
53
46
    
156
149
        handler.end_received()
157
150
        self.assertResponseIsTranslatedError(handler)
158
151
 
159
 
    def test_unexpected_error_translation(self):
160
 
        handler = request.SmartServerRequestHandler(
161
 
            None, {'foo': DoUnexpectedErrorRequest}, '/')
162
 
        handler.args_received(('foo',))
163
 
        self.assertEqual(
164
 
            request.FailedSmartServerResponse(('error', 'KeyError', "1")),
165
 
            handler.response)
166
 
 
167
152
 
168
153
class TestRequestHanderErrorTranslation(TestCase):
169
154
    """Tests for bzrlib.smart.request._translate_error."""
187
172
            ('TokenMismatch', 'some-token', 'actual-token'),
188
173
            errors.TokenMismatch('some-token', 'actual-token'))
189
174
 
190
 
    def test_MemoryError(self):
191
 
        self.assertTranslationEqual(("MemoryError",), MemoryError())
192
 
 
193
 
    def test_generic_Exception(self):
194
 
        self.assertTranslationEqual(('error', 'Exception', ""),
195
 
            Exception())
196
 
 
197
 
    def test_generic_BzrError(self):
198
 
        self.assertTranslationEqual(('error', 'BzrError', "some text"),
199
 
            errors.BzrError(msg="some text"))
200
 
 
201
 
    def test_generic_zlib_error(self):
202
 
        from zlib import error
203
 
        msg = "Error -3 while decompressing data: incorrect data check"
204
 
        self.assertTranslationEqual(('error', 'zlib.error', msg),
205
 
            error(msg))
206
 
 
207
175
 
208
176
class TestRequestJail(TestCaseWithMemoryTransport):
209
177