~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        bzrdir,
28
28
        errors,
29
29
        osutils,
30
 
        smart,
31
30
        tests,
32
31
        urlutils,
33
32
        )
740
739
        self.assertTrue(server.finished)
741
740
        
742
741
    def test_socket_stream_error_handling(self):
743
 
        # Use plain python StringIO so we can monkey-patch the close method to
744
 
        # not discard the contents.
745
 
        from StringIO import StringIO
746
742
        server_sock, client_sock = self.portable_socket_pair()
747
743
        server = medium.SmartServerSocketStreamMedium(
748
744
            server_sock, None)
754
750
        self.assertTrue(server.finished)
755
751
        
756
752
    def test_pipe_like_stream_keyboard_interrupt_handling(self):
757
 
        # Use plain python StringIO so we can monkey-patch the close method to
758
 
        # not discard the contents.
759
753
        to_server = StringIO('')
760
754
        from_server = StringIO()
761
755
        server = medium.SmartServerPipeStreamMedium(
795
789
                self.assertContainsRe(str(e), 'some random exception')
796
790
            else:
797
791
                self.fail("get did not raise expected error")
 
792
            transport.disconnect()
798
793
        finally:
799
794
            smart_server.stop_background_thread()
800
795
 
1016
1011
 
1017
1012
    def build_handler(self, transport):
1018
1013
        """Returns a handler for the commands in protocol version one."""
1019
 
        return smart.SmartServerRequestHandler(transport, request.request_handlers)
 
1014
        return request.SmartServerRequestHandler(transport,
 
1015
                                                 request.request_handlers)
1020
1016
 
1021
1017
    def test_construct_request_handler(self):
1022
1018
        """Constructing a request handler should be easy and set defaults."""
1023
 
        handler = smart.SmartServerRequestHandler(None, None)
 
1019
        handler = request.SmartServerRequestHandler(None, None)
1024
1020
        self.assertFalse(handler.finished_reading)
1025
1021
 
1026
1022
    def test_hello(self):
1447
1443
 
1448
1444
 
1449
1445
class TestSmartClientUnicode(tests.TestCase):
1450
 
    """SmartClient tests for unicode arguments.
 
1446
    """_SmartClient tests for unicode arguments.
1451
1447
 
1452
1448
    Unicode arguments to call_with_body_bytes are not correct (remote method
1453
1449
    names, arguments, and bodies must all be expressed as byte strings), but
1454
 
    SmartClient should gracefully reject them, rather than getting into a broken
1455
 
    state that prevents future correct calls from working.  That is, it should
1456
 
    be possible to issue more requests on the medium afterwards, rather than
1457
 
    allowing one bad call to call_with_body_bytes to cause later calls to
 
1450
    _SmartClient should gracefully reject them, rather than getting into a
 
1451
    broken state that prevents future correct calls from working.  That is, it
 
1452
    should be possible to issue more requests on the medium afterwards, rather
 
1453
    than allowing one bad call to call_with_body_bytes to cause later calls to
1458
1454
    mysteriously fail with TooManyConcurrentRequests.
1459
1455
    """
1460
1456
 
1466
1462
        input = StringIO("\n")
1467
1463
        output = StringIO()
1468
1464
        client_medium = medium.SmartSimplePipesClientMedium(input, output)
1469
 
        smart_client = client.SmartClient(client_medium)
 
1465
        smart_client = client._SmartClient(client_medium)
1470
1466
        self.assertRaises(TypeError,
1471
1467
            smart_client.call_with_body_bytes, method, args, body)
1472
1468
        self.assertEqual("", output.getvalue())