~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_request.py

  • Committer: John Arbash Meinel
  • Date: 2011-07-18 14:22:20 UTC
  • mto: This revision was merged to the branch mainline in revision 6033.
  • Revision ID: john@arbash-meinel.com-20110718142220-nwylw659oip1ene9
Start at least testing the package_branch regex.
And start testing the is-up-to-date logic.

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
 
44
51
class ChunkErrorRequest(request.SmartServerRequest):
45
52
    """A request that raises an error from self.do_chunk()."""
46
53
    
149
156
        handler.end_received()
150
157
        self.assertResponseIsTranslatedError(handler)
151
158
 
 
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
 
152
167
 
153
168
class TestRequestHanderErrorTranslation(TestCase):
154
169
    """Tests for bzrlib.smart.request._translate_error."""
172
187
            ('TokenMismatch', 'some-token', 'actual-token'),
173
188
            errors.TokenMismatch('some-token', 'actual-token'))
174
189
 
 
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
 
175
207
 
176
208
class TestRequestJail(TestCaseWithMemoryTransport):
177
209