/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Gordon Tyler
  • Date: 2011-09-09 12:42:32 UTC
  • mto: (6015.33.4 2.4)
  • mto: This revision was merged to the branch mainline in revision 6134.
  • Revision ID: gordon@doxxx.net-20110909124232-ip0bgx4tx6y5fya6
Use get_user_option in get_merge_tools so that quoted values are correctly unquoted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
from bzrlib.transport import (
32
32
    chroot,
33
33
    fakenfs,
 
34
    http,
34
35
    local,
35
36
    memory,
36
37
    pathfilter,
563
564
        server = HttpServer()
564
565
        self.start_server(server)
565
566
        t = transport.get_transport('readonly+' + server.get_url())
566
 
        self.failUnless(isinstance(t, readonly.ReadonlyTransportDecorator))
 
567
        self.assertIsInstance(t, readonly.ReadonlyTransportDecorator)
567
568
        self.assertEqual(False, t.listable())
568
569
        self.assertEqual(True, t.is_readonly())
569
570
 
722
723
        self.assertEquals(t.local_abspath(''), here)
723
724
 
724
725
 
 
726
class TestLocalTransportWriteStream(tests.TestCaseWithTransport):
 
727
 
 
728
    def test_local_fdatasync_calls_fdatasync(self):
 
729
        """Check fdatasync on a stream tries to flush the data to the OS.
 
730
        
 
731
        We can't easily observe the external effect but we can at least see
 
732
        it's called.
 
733
        """
 
734
        t = self.get_transport('.')
 
735
        calls = self.recordCalls(os, 'fdatasync')
 
736
        w = t.open_write_stream('out')
 
737
        w.write('foo')
 
738
        w.fdatasync()
 
739
        with open('out', 'rb') as f:
 
740
            # Should have been flushed.
 
741
            self.assertEquals(f.read(), 'foo')
 
742
        self.assertEquals(len(calls), 1, calls)
 
743
 
 
744
 
725
745
class TestWin32LocalTransport(tests.TestCase):
726
746
 
727
747
    def test_unc_clone_to_root(self):
746
766
        self.assertEquals(t._host, 'simple.example.com')
747
767
        self.assertEquals(t._port, None)
748
768
        self.assertEquals(t._path, '/home/source/')
749
 
        self.failUnless(t._user is None)
750
 
        self.failUnless(t._password is None)
 
769
        self.assertTrue(t._user is None)
 
770
        self.assertTrue(t._password is None)
751
771
 
752
772
        self.assertEquals(t.base, 'http://simple.example.com/home/source/')
753
773
 
955
975
        ssh_server = stub_sftp.SFTPFullAbsoluteServer(StubSSHServer)
956
976
        # We *don't* want to override the default SSH vendor: the detected one
957
977
        # is the one to use.
 
978
 
 
979
        # FIXME: I don't understand the above comment, SFTPFullAbsoluteServer
 
980
        # inherits from SFTPServer which forces the SSH vendor to
 
981
        # ssh.ParamikoVendor(). So it's forced, not detected. --vila 20100623
958
982
        self.start_server(ssh_server)
959
 
        port = ssh_server._listener.port
 
983
        port = ssh_server.port
960
984
 
961
985
        if sys.platform == 'win32':
962
986
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
963
987
        else:
964
988
            bzr_remote_path = self.get_bzr_path()
965
 
        os.environ['BZR_REMOTE_PATH'] = bzr_remote_path
 
989
        self.overrideEnv('BZR_REMOTE_PATH', bzr_remote_path)
966
990
 
967
991
        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
968
992
        # variable is used to tell bzr what command to run on the remote end.
989
1013
        # And the rest are threads
990
1014
        for t in started[1:]:
991
1015
            t.join()
 
1016
 
 
1017
 
 
1018
class TestUnhtml(tests.TestCase):
 
1019
 
 
1020
    """Tests for unhtml_roughly"""
 
1021
 
 
1022
    def test_truncation(self):
 
1023
        fake_html = "<p>something!\n" * 1000
 
1024
        result = http.unhtml_roughly(fake_html)
 
1025
        self.assertEquals(len(result), 1000)
 
1026
        self.assertStartsWith(result, " something!")