Rev 2180: Test only fixes from the ported-to-bzr.dev test-correctness branch. in http://bazaar.launchpad.net/~bzr/bzr/hpss

Robert Collins robertc at robertcollins.net
Wed Mar 28 08:51:17 BST 2007


At http://bazaar.launchpad.net/~bzr/bzr/hpss

------------------------------------------------------------
revno: 2180
revision-id: robertc at robertcollins.net-20070328074837-v6jlmuzlbwcpfu7o
parent: robertc at robertcollins.net-20070328052828-mubnf4b0llxumi2b
parent: robertc at robertcollins.net-20070328073307-ni7dcww9b1rf0udp
committer: Robert Collins <robertc at robertcollins.net>
branch nick: hpss
timestamp: Wed 2007-03-28 17:48:37 +1000
message:
  Test only fixes from the ported-to-bzr.dev test-correctness branch.
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/branch_implementations/test_http.py test_http.py-20060731224648-2eef7ae5yja95rya-1
  bzrlib/tests/branch_implementations/test_locking.py test_locking.py-20060707151933-tav3o2hpibwi53u4-4
  bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
  bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
  bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
  bzrlib/transport/sftp.py       sftp.py-20051019050329-ab48ce71b7e32dfe
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.3
    merged: robertc at robertcollins.net-20070328073307-ni7dcww9b1rf0udp
    parent: pqm at pqm.ubuntu.com-20070328065822-999550a858a3ced3
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: hpss-test-correctness
    timestamp: Wed 2007-03-28 17:33:07 +1000
    message:
      Split out hpss test fixes which dont depend on new or altered API's.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2
    merged: pqm at pqm.ubuntu.com-20070328065822-999550a858a3ced3
    parent: pqm at pqm.ubuntu.com-20070328022809-40aa40f8edf4e502
    parent: robertc at robertcollins.net-20070328051901-x5osh1c7fk75ira8
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-03-28 07:58:22 +0100
    message:
      (robertc) Fix chroot urls to not expose the url of the transport they are protecting, allowing regular url operations to work on them. (Robert Collins, Andrew Bennetts)
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.1
    merged: pqm at pqm.ubuntu.com-20070328022809-40aa40f8edf4e502
    parent: pqm at pqm.ubuntu.com-20070327081802-271be0d343108f4f
    parent: robertc at robertcollins.net-20070327214317-2hqvbmbcztm9ycqb
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-03-28 03:28:09 +0100
    message:
      (robertc) urlutils improvements split out from the hpss branch (Andrew Bennetts, Robert Collins)
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-03-27 21:45:59 +0000
+++ b/bzrlib/tests/__init__.py	2007-03-28 07:48:37 +0000
@@ -1608,12 +1608,18 @@
         then the self.get_vfs_server is returned.
         """
         if self.__server is None:
-            if self.transport_server is None:
+            if self.transport_server is None or self.transport_server is self.vfs_transport_factory:
                 return self.get_vfs_only_server()
             else:
                 # bring up a decorated means of access to the vfs only server.
                 self.__server = self.transport_server()
-                self.__server.setUp(self.get_vfs_only_server())
+                try:
+                    self.__server.setUp(self.get_vfs_only_server())
+                except TypeError, e:
+                    # This should never happen; the try:Except here is to assist
+                    # developers having to update code rather than seeing an
+                    # uninformative TypeError.
+                    raise Exception, "Old server API in use: %s, %s" % (self.__server, e)
             self.addCleanup(self.__server.tearDown)
         return self.__server
 
@@ -1923,7 +1929,13 @@
             # We can only make working trees locally at the moment.  If the
             # transport can't support them, then we keep the non-disk-backed
             # branch and create a local checkout.
-            return b.create_checkout(relpath, lightweight=True)
+            if self.vfs_transport_factory is LocalURLServer:
+                # the branch is colocated on disk, we cannot create a checkout.
+                # hopefully callers will expect this.
+                local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))
+                return local_controldir.create_workingtree()
+            else:
+                return b.create_checkout(relpath, lightweight=True)
 
     def assertIsDirectory(self, relpath, transport):
         """Assert that relpath within transport is a directory.

=== modified file 'bzrlib/tests/branch_implementations/test_http.py'
--- a/bzrlib/tests/branch_implementations/test_http.py	2007-03-27 09:46:24 +0000
+++ b/bzrlib/tests/branch_implementations/test_http.py	2007-03-28 07:48:37 +0000
@@ -36,8 +36,8 @@
 
     def setUp(self):
         super(InaccessibleParentTests, self).setUp()
-        if self.vfs_transport_factory is LocalURLServer:
-            self.vfs_transport_factory = TestingChrootServer
+        if self.transport_server in (LocalURLServer, None):
+            self.transport_readonly_server = TestingChrootServer
 
     def get_branch_with_invalid_parent(self):
         """Get a branch whose get_parent will raise InaccessibleParent."""

=== modified file 'bzrlib/tests/branch_implementations/test_locking.py'
--- a/bzrlib/tests/branch_implementations/test_locking.py	2007-03-01 01:22:34 +0000
+++ b/bzrlib/tests/branch_implementations/test_locking.py	2007-03-28 07:48:37 +0000
@@ -448,9 +448,3 @@
             branch.repository.unlock()
         finally:
             branch.unlock()
-
-    #def test_lock_read_locks_repo_too(self):
-    #    branch = self.make_branch('b')
-
-
-

=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2007-03-13 06:55:43 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2007-03-28 07:48:37 +0000
@@ -77,6 +77,7 @@
         self.assertIsInstance(tree.branch.repository._format,
             self.repository_format.__class__)
 
+
 class TestRepository(TestCaseWithRepository):
 
     def test_clone_to_default_format(self):
@@ -100,7 +101,7 @@
         second_revision = tree.commit('')
         inv = tree.branch.repository.revision_tree(second_revision).inventory
         rich_root = (inv.root.revision != second_revision)
-        self.assertEqual(rich_root, 
+        self.assertEqual(rich_root,
                          tree.branch.repository.supports_rich_root())
 
     def test_clone_specific_format(self):

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2007-03-27 06:42:26 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2007-03-28 07:48:37 +0000
@@ -454,6 +454,12 @@
                          local_branch_path(branch))
         self.assertIs(tree.bzrdir, branch.bzrdir)
         self.assertEqual('foo', relpath)
+        # opening from non-local should not return the tree
+        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
+            self.get_readonly_url('topdir/foo'))
+        self.assertEqual(None, tree)
+        self.assertEqual('foo', relpath)
+        # without a tree:
         self.make_branch('topdir/foo')
         tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
             'topdir/foo')
@@ -758,10 +764,3 @@
         checkout_format = my_bzrdir.checkout_metadir()
         self.assertIsInstance(checkout_format.workingtree_format,
                               workingtree.WorkingTreeFormat3)
-
-
-class TestRemoteSFTP(test_sftp_transport.TestCaseWithSFTPServer):
-
-    def test_open_containing_tree_or_branch(self):
-        tree = self.make_branch_and_tree('tree')
-        bzrdir.BzrDir.open_containing_tree_or_branch(self.get_url('tree'))

=== modified file 'bzrlib/tests/test_sftp_transport.py'
--- a/bzrlib/tests/test_sftp_transport.py	2007-03-27 06:42:26 +0000
+++ b/bzrlib/tests/test_sftp_transport.py	2007-03-28 07:48:37 +0000
@@ -57,7 +57,7 @@
         super(TestCaseWithSFTPServer, self).setUp()
         if not paramiko_loaded:
             raise TestSkipped('you must have paramiko to run this test')
-        set_test_transport_to_sftp(self) 
+        set_test_transport_to_sftp(self)
 
     def get_transport(self, path=None):
         """Return a transport relative to self._test_root."""

=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py	2007-03-13 06:55:43 +0000
+++ b/bzrlib/transport/remote.py	2007-03-28 07:48:37 +0000
@@ -727,18 +727,25 @@
         SmartTCPServer.__init__(self,
             transport.get_transport(urlutils.local_path_to_url('/')))
         
-    def setUp(self):
+    def get_backing_transport(self, backing_transport_server):
+        """Get a backing transport from a server we are decorating."""
+        return transport.get_transport(backing_transport_server.get_url())
+
+    def setUp(self, backing_transport_server=None):
         """Set up server for testing"""
+        from bzrlib.transport.chroot import TestingChrootServer
+        if backing_transport_server is None:
+            from bzrlib.transport.local import LocalURLServer
+            backing_transport_server = LocalURLServer()
+        self.chroot_server = TestingChrootServer()
+        self.chroot_server.setUp(backing_transport_server)
+        self.backing_transport = transport.get_transport(
+            self.chroot_server.get_url())
         self.start_background_thread()
 
     def tearDown(self):
         self.stop_background_thread()
 
-    def get_url(self):
-        """Return the url of the server"""
-        host, port = self._server_socket.getsockname()
-        return "bzr://%s:%d%s" % (host, port, urlutils.escape(self._homedir))
-
     def get_bogus_url(self):
         """Return a URL which will fail to connect"""
         return 'bzr://127.0.0.1:1/'

=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py	2007-03-27 06:42:26 +0000
+++ b/bzrlib/transport/sftp.py	2007-03-28 07:48:37 +0000
@@ -56,6 +56,7 @@
     ssh,
     Transport,
     )
+from bzrlib.transport.local import LocalURLServer
 
 try:
     import paramiko
@@ -1068,7 +1069,10 @@
         ssh_server.start_server(event, server)
         event.wait(5.0)
     
-    def setUp(self):
+    def setUp(self, vfs_server=None):
+        # XXX: TODO: make sftpserver back onto vfs_server rather than local disk.
+        assert vfs_server is None or isinstance(vfs_server, LocalURLServer), \
+            "SFTPServer currently assumes local transport, got %s" % vfs_server
         self._original_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
         ssh._ssh_vendor_manager._cached_ssh_vendor = self._vendor
         if sys.platform == 'win32':



More information about the bazaar-commits mailing list