~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2007-04-11 02:01:18 UTC
  • mto: This revision was merged to the branch mainline in revision 2404.
  • Revision ID: andrew.bennetts@canonical.com-20070411020118-yie55yxj8v9ke3b8
Deal with review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
577
577
 
578
578
    def setUp(self):
579
579
        super(TestSmartServerStreamMedium, self).setUp()
580
 
        self._captureVar('NO_SMART_VFS', None)
 
580
        self._captureVar('BZR_NO_SMART_VFS', None)
581
581
 
582
582
    def portable_socket_pair(self):
583
583
        """Return a pair of TCP sockets connected to each other.
785
785
 
786
786
    def test_get_error_unexpected(self):
787
787
        """Error reported by server with no specific representation"""
788
 
        self._captureVar('NO_SMART_VFS', None)
 
788
        self._captureVar('BZR_NO_SMART_VFS', None)
789
789
        class FlakyTransport(object):
790
790
            base = 'a_url'
791
791
            def get_bytes(self, path):
871
871
 
872
872
    def test_smart_transport_has(self):
873
873
        """Checking for file existence over smart."""
874
 
        self._captureVar('NO_SMART_VFS', None)
 
874
        self._captureVar('BZR_NO_SMART_VFS', None)
875
875
        self.backing_transport.put_bytes("foo", "contents of foo\n")
876
876
        self.assertTrue(self.transport.has("foo"))
877
877
        self.assertFalse(self.transport.has("non-foo"))
878
878
 
879
879
    def test_smart_transport_get(self):
880
880
        """Read back a file over smart."""
881
 
        self._captureVar('NO_SMART_VFS', None)
 
881
        self._captureVar('BZR_NO_SMART_VFS', None)
882
882
        self.backing_transport.put_bytes("foo", "contents\nof\nfoo\n")
883
883
        fp = self.transport.get("foo")
884
884
        self.assertEqual('contents\nof\nfoo\n', fp.read())
888
888
        # The path in a raised NoSuchFile exception should be the precise path
889
889
        # asked for by the client. This gives meaningful and unsurprising errors
890
890
        # for users.
891
 
        self._captureVar('NO_SMART_VFS', None)
 
891
        self._captureVar('BZR_NO_SMART_VFS', None)
892
892
        try:
893
893
            self.transport.get('not%20a%20file')
894
894
        except errors.NoSuchFile, e:
915
915
 
916
916
    def test_open_dir(self):
917
917
        """Test changing directory"""
918
 
        self._captureVar('NO_SMART_VFS', None)
 
918
        self._captureVar('BZR_NO_SMART_VFS', None)
919
919
        transport = self.transport
920
920
        self.backing_transport.mkdir('toffee')
921
921
        self.backing_transport.mkdir('toffee/apple')
943
943
 
944
944
    def test_mkdir_error_readonly(self):
945
945
        """TransportNotPossible should be preserved from the backing transport."""
946
 
        self._captureVar('NO_SMART_VFS', None)
 
946
        self._captureVar('BZR_NO_SMART_VFS', None)
947
947
        self.setUpServer(readonly=True)
948
948
        self.assertRaises(errors.TransportNotPossible, self.transport.mkdir,
949
949
            'foo')
1017
1017
 
1018
1018
    def setUp(self):
1019
1019
        super(SmartServerRequestHandlerTests, self).setUp()
1020
 
        self._captureVar('NO_SMART_VFS', None)
 
1020
        self._captureVar('BZR_NO_SMART_VFS', None)
1021
1021
 
1022
1022
    def build_handler(self, transport):
1023
1023
        """Returns a handler for the commands in protocol version one."""
1035
1035
        self.assertEqual(None, handler.response.body)
1036
1036
        
1037
1037
    def test_disable_vfs_handler_classes_via_environment(self):
1038
 
        # VFS handler classes will raise an error from "execute" if NO_SMART_VFS
 
1038
        # VFS handler classes will raise an error from "execute" if BZR_NO_SMART_VFS
1039
1039
        # is set.
1040
1040
        handler = vfs.HasRequest(None)
1041
1041
        # set environment variable after construction to make sure it's
1042
1042
        # examined.
1043
 
        # Note that we can safely clobber NO_SMART_VFS here, because setUp has
 
1043
        # Note that we can safely clobber BZR_NO_SMART_VFS here, because setUp has
1044
1044
        # called _captureVar, so it will be restored to the right state
1045
1045
        # afterwards.
1046
 
        os.environ['NO_SMART_VFS'] = ''
 
1046
        os.environ['BZR_NO_SMART_VFS'] = ''
1047
1047
        self.assertRaises(errors.DisabledMethod, handler.execute)
1048
1048
 
1049
1049
    def test_readonly_exception_becomes_transport_not_possible(self):
1274
1274
        self.assertTrue(self.end_received)
1275
1275
 
1276
1276
    def test_accept_request_and_body_all_at_once(self):
1277
 
        self._captureVar('NO_SMART_VFS', None)
 
1277
        self._captureVar('BZR_NO_SMART_VFS', None)
1278
1278
        mem_transport = memory.MemoryTransport()
1279
1279
        mem_transport.put_bytes('foo', 'abcdefghij')
1280
1280
        out_stream = StringIO()
1532
1532
    def setUp(self):
1533
1533
        super(HTTPTunnellingSmokeTest, self).setUp()
1534
1534
        # We use the VFS layer as part of HTTP tunnelling tests.
1535
 
        self._captureVar('NO_SMART_VFS', None)
 
1535
        self._captureVar('BZR_NO_SMART_VFS', None)
1536
1536
 
1537
1537
    def _test_bulk_data(self, url_protocol):
1538
1538
        # We should be able to send and receive bulk data in a single message.