~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
572
572
 
573
573
    def setUp(self):
574
574
        super(TestSmartServerStreamMedium, self).setUp()
575
 
        self._captureVar('NO_SMART_VFS', None)
 
575
        self._captureVar('BZR_NO_SMART_VFS', None)
576
576
 
577
577
    def portable_socket_pair(self):
578
578
        """Return a pair of TCP sockets connected to each other.
780
780
 
781
781
    def test_get_error_unexpected(self):
782
782
        """Error reported by server with no specific representation"""
783
 
        self._captureVar('NO_SMART_VFS', None)
 
783
        self._captureVar('BZR_NO_SMART_VFS', None)
784
784
        class FlakyTransport(object):
785
785
            base = 'a_url'
786
786
            def get_bytes(self, path):
866
866
 
867
867
    def test_smart_transport_has(self):
868
868
        """Checking for file existence over smart."""
869
 
        self._captureVar('NO_SMART_VFS', None)
 
869
        self._captureVar('BZR_NO_SMART_VFS', None)
870
870
        self.backing_transport.put_bytes("foo", "contents of foo\n")
871
871
        self.assertTrue(self.transport.has("foo"))
872
872
        self.assertFalse(self.transport.has("non-foo"))
873
873
 
874
874
    def test_smart_transport_get(self):
875
875
        """Read back a file over smart."""
876
 
        self._captureVar('NO_SMART_VFS', None)
 
876
        self._captureVar('BZR_NO_SMART_VFS', None)
877
877
        self.backing_transport.put_bytes("foo", "contents\nof\nfoo\n")
878
878
        fp = self.transport.get("foo")
879
879
        self.assertEqual('contents\nof\nfoo\n', fp.read())
883
883
        # The path in a raised NoSuchFile exception should be the precise path
884
884
        # asked for by the client. This gives meaningful and unsurprising errors
885
885
        # for users.
886
 
        self._captureVar('NO_SMART_VFS', None)
 
886
        self._captureVar('BZR_NO_SMART_VFS', None)
887
887
        try:
888
888
            self.transport.get('not%20a%20file')
889
889
        except errors.NoSuchFile, e:
910
910
 
911
911
    def test_open_dir(self):
912
912
        """Test changing directory"""
913
 
        self._captureVar('NO_SMART_VFS', None)
 
913
        self._captureVar('BZR_NO_SMART_VFS', None)
914
914
        transport = self.transport
915
915
        self.backing_transport.mkdir('toffee')
916
916
        self.backing_transport.mkdir('toffee/apple')
938
938
 
939
939
    def test_mkdir_error_readonly(self):
940
940
        """TransportNotPossible should be preserved from the backing transport."""
941
 
        self._captureVar('NO_SMART_VFS', None)
 
941
        self._captureVar('BZR_NO_SMART_VFS', None)
942
942
        self.setUpServer(readonly=True)
943
943
        self.assertRaises(errors.TransportNotPossible, self.transport.mkdir,
944
944
            'foo')
1012
1012
 
1013
1013
    def setUp(self):
1014
1014
        super(SmartServerRequestHandlerTests, self).setUp()
1015
 
        self._captureVar('NO_SMART_VFS', None)
 
1015
        self._captureVar('BZR_NO_SMART_VFS', None)
1016
1016
 
1017
1017
    def build_handler(self, transport):
1018
1018
        """Returns a handler for the commands in protocol version one."""
1030
1030
        self.assertEqual(None, handler.response.body)
1031
1031
        
1032
1032
    def test_disable_vfs_handler_classes_via_environment(self):
1033
 
        # VFS handler classes will raise an error from "execute" if NO_SMART_VFS
1034
 
        # is set.
 
1033
        # VFS handler classes will raise an error from "execute" if
 
1034
        # BZR_NO_SMART_VFS is set.
1035
1035
        handler = vfs.HasRequest(None)
1036
1036
        # set environment variable after construction to make sure it's
1037
1037
        # examined.
1038
 
        # Note that we can safely clobber NO_SMART_VFS here, because setUp has
1039
 
        # called _captureVar, so it will be restored to the right state
 
1038
        # Note that we can safely clobber BZR_NO_SMART_VFS here, because setUp
 
1039
        # has called _captureVar, so it will be restored to the right state
1040
1040
        # afterwards.
1041
 
        os.environ['NO_SMART_VFS'] = ''
 
1041
        os.environ['BZR_NO_SMART_VFS'] = ''
1042
1042
        self.assertRaises(errors.DisabledMethod, handler.execute)
1043
1043
 
1044
1044
    def test_readonly_exception_becomes_transport_not_possible(self):
1176
1176
        self.client_protocol = protocol.SmartClientRequestProtocolOne(
1177
1177
            self.client_medium)
1178
1178
        self.smart_server = InstrumentedServerProtocol(self.server_to_client)
1179
 
        self.smart_server_request = smart.SmartServerRequestHandler(
 
1179
        self.smart_server_request = request.SmartServerRequestHandler(
1180
1180
            None, request.request_handlers)
1181
1181
 
1182
1182
    def assertOffsetSerialisation(self, expected_offsets, expected_serialised,
1269
1269
        self.assertTrue(self.end_received)
1270
1270
 
1271
1271
    def test_accept_request_and_body_all_at_once(self):
1272
 
        self._captureVar('NO_SMART_VFS', None)
 
1272
        self._captureVar('BZR_NO_SMART_VFS', None)
1273
1273
        mem_transport = memory.MemoryTransport()
1274
1274
        mem_transport.put_bytes('foo', 'abcdefghij')
1275
1275
        out_stream = StringIO()
1563
1563
    def setUp(self):
1564
1564
        super(HTTPTunnellingSmokeTest, self).setUp()
1565
1565
        # We use the VFS layer as part of HTTP tunnelling tests.
1566
 
        self._captureVar('NO_SMART_VFS', None)
 
1566
        self._captureVar('BZR_NO_SMART_VFS', None)
1567
1567
 
1568
1568
    def _test_bulk_data(self, url_protocol):
1569
1569
        # We should be able to send and receive bulk data in a single message.