Rev 5018: Create a tests.test_server.TestServer class out of transport.Server (while retaining the later for some special non-tests usages). in file:///home/vila/src/bzr/cleanup/test-servers/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Feb 9 16:40:30 GMT 2010


At file:///home/vila/src/bzr/cleanup/test-servers/

------------------------------------------------------------
revno: 5018
revision-id: v.ladeuil+lp at free.fr-20100209164030-oa6bos3m5fshecp0
parent: pqm at pqm.ubuntu.com-20100209142113-o8yqxlo2kqgp98q0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: test-servers
timestamp: Tue 2010-02-09 17:40:30 +0100
message:
  Create a tests.test_server.TestServer class out of transport.Server (while retaining the later for some special non-tests usages).
-------------- next part --------------
=== added file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_server.py	2010-02-09 16:40:30 +0000
@@ -0,0 +1,55 @@
+# Copyright (C) 2005, 2006, 2007, 2008, 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from bzrlib import (
+    transport,
+    )
+
+
+class TestServer(transport.Server):
+    """A Transport Server dedicated to tests.
+
+    The TestServer interface provides a server for a given transport. We use
+    these servers as loopback testing tools. For any given transport the
+    Servers it provides must either allow writing, or serve the contents
+    of os.getcwdu() at the time start_server is called.
+
+    Note that these are real servers - they must implement all the things
+    that we want bzr transports to take advantage of.
+    """
+
+    def get_url(self):
+        """Return a url for this server.
+
+        If the transport does not represent a disk directory (i.e. it is
+        a database like svn, or a memory only transport, it should return
+        a connection to a newly established resource for this Server.
+        Otherwise it should return a url that will provide access to the path
+        that was os.getcwdu() when start_server() was called.
+
+        Subsequent calls will return the same resource.
+        """
+        raise NotImplementedError
+
+    def get_bogus_url(self):
+        """Return a url for this protocol, that will fail to connect.
+
+        This may raise NotImplementedError to indicate that this server cannot
+        provide bogus urls.
+        """
+        raise NotImplementedError
+
+

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2010-01-07 03:03:01 +0000
+++ b/bzrlib/transport/__init__.py	2010-02-09 16:40:30 +0000
@@ -1663,13 +1663,7 @@
 class Server(object):
     """A Transport Server.
 
-    The Server interface provides a server for a given transport. We use
-    these servers as loopback testing tools. For any given transport the
-    Servers it provides must either allow writing, or serve the contents
-    of os.getcwdu() at the time start_server is called.
-
-    Note that these are real servers - they must implement all the things
-    that we want bzr transports to take advantage of.
+    The Server interface provides a server for a given transport type.
     """
 
     def start_server(self):
@@ -1678,27 +1672,6 @@
     def stop_server(self):
         """Remove the server and cleanup any resources it owns."""
 
-    def get_url(self):
-        """Return a url for this server.
-
-        If the transport does not represent a disk directory (i.e. it is
-        a database like svn, or a memory only transport, it should return
-        a connection to a newly established resource for this Server.
-        Otherwise it should return a url that will provide access to the path
-        that was os.getcwdu() when start_server() was called.
-
-        Subsequent calls will return the same resource.
-        """
-        raise NotImplementedError
-
-    def get_bogus_url(self):
-        """Return a url for this protocol, that will fail to connect.
-
-        This may raise NotImplementedError to indicate that this server cannot
-        provide bogus urls.
-        """
-        raise NotImplementedError
-
 
 # None is the default transport, for things with no url scheme
 register_transport_proto('file://',



More information about the bazaar-commits mailing list