~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Martin Pool
  • Date: 2010-01-07 03:03:01 UTC
  • mto: This revision was merged to the branch mainline in revision 4943.
  • Revision ID: mbp@sourcefrog.net-20100107030301-a8r5ur1qsp2vukx5
Rename Server.setUp to Server.start_server

Show diffs side-by-side

added added

removed removed

Lines of Context:
987
987
    All of these tests are run with a server running on another thread serving
988
988
    a MemoryTransport, and a connection to it already open.
989
989
 
990
 
    the server is obtained by calling self.setUpServer(readonly=False).
 
990
    the server is obtained by calling self.start_server(readonly=False).
991
991
    """
992
992
 
993
 
    def setUpServer(self, readonly=False, backing_transport=None):
 
993
    def start_server(self, readonly=False, backing_transport=None):
994
994
        """Setup the server.
995
995
 
996
996
        :param readonly: Create a readonly server.
1000
1000
        # self.vfs_transport_factory etc.
1001
1001
        if not backing_transport:
1002
1002
            mem_server = memory.MemoryServer()
1003
 
            mem_server.setUp()
 
1003
            mem_server.start_server()
1004
1004
            self.addCleanup(mem_server.stop_server)
1005
1005
            self.permit_url(mem_server.get_url())
1006
1006
            self.backing_transport = get_transport(mem_server.get_url())
1029
1029
 
1030
1030
    def test_server_setup_teardown(self):
1031
1031
        """It should be safe to teardown the server with no requests."""
1032
 
        self.setUpServer()
 
1032
        self.start_server()
1033
1033
        server = self.server
1034
1034
        transport = remote.RemoteTCPTransport(self.server.get_url())
1035
1035
        self.tearDownServer()
1037
1037
 
1038
1038
    def test_server_closes_listening_sock_on_shutdown_after_request(self):
1039
1039
        """The server should close its listening socket when it's stopped."""
1040
 
        self.setUpServer()
 
1040
        self.start_server()
1041
1041
        server = self.server
1042
1042
        self.transport.has('.')
1043
1043
        self.tearDownServer()
1052
1052
 
1053
1053
    def setUp(self):
1054
1054
        super(WritableEndToEndTests, self).setUp()
1055
 
        self.setUpServer()
 
1055
        self.start_server()
1056
1056
 
1057
1057
    def test_start_tcp_server(self):
1058
1058
        url = self.server.get_url()
1131
1131
    def test_mkdir_error_readonly(self):
1132
1132
        """TransportNotPossible should be preserved from the backing transport."""
1133
1133
        self._captureVar('BZR_NO_SMART_VFS', None)
1134
 
        self.setUpServer(readonly=True)
 
1134
        self.start_server(readonly=True)
1135
1135
        self.assertRaises(errors.TransportNotPossible, self.transport.mkdir,
1136
1136
            'foo')
1137
1137
 
1147
1147
        self.hook_calls = []
1148
1148
        server.SmartTCPServer.hooks.install_named_hook('server_started',
1149
1149
            self.capture_server_call, None)
1150
 
        self.setUpServer()
 
1150
        self.start_server()
1151
1151
        # at this point, the server will be starting a thread up.
1152
1152
        # there is no indicator at the moment, so bodge it by doing a request.
1153
1153
        self.transport.has('.')
1161
1161
        self.hook_calls = []
1162
1162
        server.SmartTCPServer.hooks.install_named_hook('server_started',
1163
1163
            self.capture_server_call, None)
1164
 
        self.setUpServer(backing_transport=get_transport("."))
 
1164
        self.start_server(backing_transport=get_transport("."))
1165
1165
        # at this point, the server will be starting a thread up.
1166
1166
        # there is no indicator at the moment, so bodge it by doing a request.
1167
1167
        self.transport.has('.')
1177
1177
        self.hook_calls = []
1178
1178
        server.SmartTCPServer.hooks.install_named_hook('server_stopped',
1179
1179
            self.capture_server_call, None)
1180
 
        self.setUpServer()
 
1180
        self.start_server()
1181
1181
        result = [([self.backing_transport.base], self.transport.base)]
1182
1182
        # check the stopping message isn't emitted up front.
1183
1183
        self.assertEqual([], self.hook_calls)
1194
1194
        self.hook_calls = []
1195
1195
        server.SmartTCPServer.hooks.install_named_hook('server_stopped',
1196
1196
            self.capture_server_call, None)
1197
 
        self.setUpServer(backing_transport=get_transport("."))
 
1197
        self.start_server(backing_transport=get_transport("."))
1198
1198
        result = [(
1199
1199
            [self.backing_transport.base, self.backing_transport.external_url()]
1200
1200
            , self.transport.base)]