~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

Add test for sending ProtocolThreeResponder.send_error(UnknownSmartMethod(...)).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2437
2437
            output.getvalue())
2438
2438
 
2439
2439
 
 
2440
class TestResponseEncodingProtocolThree(tests.TestCase):
 
2441
 
 
2442
    def make_response_encoder(self):
 
2443
        out_stream = StringIO()
 
2444
        response_encoder = protocol.ProtocolThreeResponder(out_stream.write)
 
2445
        return response_encoder, out_stream
 
2446
 
 
2447
    def test_send_error_unknown_method(self):
 
2448
        encoder, out_stream = self.make_response_encoder()
 
2449
        encoder.send_error(errors.UnknownSmartMethod('method name'))
 
2450
        # Use assertEndsWith so that we don't compare the header, which varies
 
2451
        # by bzrlib.__version__.
 
2452
        self.assertEndsWith(
 
2453
            out_stream.getvalue(),
 
2454
            # error status
 
2455
            'oE' +
 
2456
            # tuple: 'UnknownMethod', 'method name'
 
2457
            's\x00\x00\x00\x20l13:UnknownMethod11:method namee'
 
2458
            # end of message
 
2459
            'e')
 
2460
 
 
2461
 
2440
2462
class TestSmartClientUnicode(tests.TestCase):
2441
2463
    """_SmartClient tests for unicode arguments.
2442
2464