remove LocalAbspathServer, LocalRelpathServer
Martin Pool
mbp at canonical.com
Fri Aug 25 05:47:51 BST 2006
On 24 Aug 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> Martin Pool wrote:
> I don't see any tests doing "directly test constructing transports from
> paths". I just see the removal of the other transport servers.
>
> +1 on removing them from me. But I'd like to see the other things tested
> first.
Sorry, I just sent the wrong bundle - just removing them as that one did
would break things. Here is the correct fix.
Getting that wrong makes me think that the current interpretation of -r
for bundle could be better. Perhaps 'bzr bundle -r -2' should give the
bundle from -2, similar to bzr diff?
# Bazaar revision bundle v0.8
#
# message:
# Actually remove Local{Abs,Rel}pathServer
# committer: Martin Pool <mbp at sourcefrog.net>
# date: Thu 2006-08-24 18:34:40.628999949 +1000
=== modified file bzrlib/tests/__init__.py // last-changed:mbp at sourcefrog.net-2
... 0060824082026-d539b3b122dc2f2a
--- bzrlib/tests/__init__.py
+++ bzrlib/tests/__init__.py
@@ -69,7 +69,7 @@
import bzrlib.trace
from bzrlib.transport import get_transport
import bzrlib.transport
-from bzrlib.transport.local import LocalRelpathServer
+from bzrlib.transport.local import LocalURLServer
from bzrlib.transport.readonly import ReadonlyServer
from bzrlib.trace import mutter
from bzrlib.tests import TestUtil
@@ -81,7 +81,7 @@
import bzrlib.urlutils as urlutils
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
-default_transport = LocalRelpathServer
+default_transport = LocalURLServer
MODULES_TO_TEST = []
MODULES_TO_DOCTEST = [
=== modified file bzrlib/tests/test_selftest.py // last-changed:mbp at sourcefrog.
... net-20060824082026-d539b3b122dc2f2a
--- bzrlib/tests/test_selftest.py
+++ bzrlib/tests/test_selftest.py
@@ -439,9 +439,9 @@
def test_get_readonly_url_http(self):
from bzrlib.transport import get_transport
- from bzrlib.transport.local import LocalRelpathServer
+ from bzrlib.transport.local import LocalURLServer
from bzrlib.transport.http import HttpServer, HttpTransportBase
- self.transport_server = LocalRelpathServer
+ self.transport_server = LocalURLServer
self.transport_readonly_server = HttpServer
# calling get_readonly_transport() gives us a HTTP server instance.
url = self.get_readonly_url()
=== modified file bzrlib/tests/test_transport.py // last-changed:mbp at sourcefrog
... .net-20060824082026-d539b3b122dc2f2a
--- bzrlib/tests/test_transport.py
+++ bzrlib/tests/test_transport.py
@@ -38,6 +38,10 @@
)
from bzrlib.transport.memory import MemoryTransport
from bzrlib.transport.local import LocalTransport
+from bzrlib import urlutils
+
+
+# TODO: Should possibly split transport-specific tests into their own files.
class TestTransport(TestCase):
@@ -319,8 +323,8 @@
server = fakenfs.FakeNFSServer()
server.setUp()
try:
- # the server should be a relpath localhost server
- self.assertEqual(server.get_url(), 'fakenfs+.')
+ # the url should be decorated appropriately
+ self.assertTrue(server.get_url().startswith('fakenfs+'))
# and we should be able to get a transport for it
transport = get_transport(server.get_url())
# which must be a FakeNFSTransportDecorator instance.
@@ -414,3 +418,25 @@
# regular connection behaviour by direct construction.
t = self.transport_class(base_url)
return t
+
+
+class TestLocalTransports(TestCase):
+
+ def test_get_transport_from_abspath(self):
+ here = os.path.abspath('.')
+ t = get_transport(here)
+ self.assertIsInstance(t, LocalTransport)
+ self.assertEquals(t.base, urlutils.local_path_to_url(here) + '/')
+
+ def test_get_transport_from_relpath(self):
+ here = os.path.abspath('.')
+ t = get_transport('.')
+ self.assertIsInstance(t, LocalTransport)
+ self.assertEquals(t.base, urlutils.local_path_to_url(here) + '/')
+
+ def test_get_transport_from_local_url(self):
+ here = os.path.abspath('.')
+ here_url = urlutils.local_path_to_url(here) + '/'
+ t = get_transport(here_url)
+ self.assertIsInstance(t, LocalTransport)
+ self.assertEquals(t.base, here_url)
=== modified file bzrlib/transport/decorator.py // last-changed:mbp at sourcefrog.
... net-20060824082026-d539b3b122dc2f2a
--- bzrlib/transport/decorator.py
+++ bzrlib/transport/decorator.py
@@ -153,9 +153,9 @@
self._made_server = False
self._server = server
else:
- from bzrlib.transport.local import LocalRelpathServer
+ from bzrlib.transport.local import LocalURLServer
self._made_server = True
- self._server = LocalRelpathServer()
+ self._server = LocalURLServer()
self._server.setUp()
def tearDown(self):
=== modified file bzrlib/transport/local.py
--- bzrlib/transport/local.py
+++ bzrlib/transport/local.py
@@ -344,24 +344,12 @@
return True
-class LocalRelpathServer(Server):
- """A pretend server for local transports, using relpaths."""
-
- def get_url(self):
- """See Transport.Server.get_url."""
- return "."
-
-
-class LocalAbspathServer(Server):
- """A pretend server for local transports, using absolute paths."""
-
- def get_url(self):
- """See Transport.Server.get_url."""
- return os.path.abspath("")
-
-
class LocalURLServer(Server):
- """A pretend server for local transports, using file:// urls."""
+ """A pretend server for local transports, using file:// urls.
+
+ Of course no actual server is required to access the local filesystem, so
+ this just exists to tell the test code how to get to it.
+ """
def get_url(self):
"""See Transport.Server.get_url."""
@@ -370,7 +358,6 @@
def get_test_permutations():
"""Return the permutations to be used in testing."""
- return [(LocalTransport, LocalRelpathServer),
- (LocalTransport, LocalAbspathServer),
+ return [
(LocalTransport, LocalURLServer),
]
# revision id: mbp at sourcefrog.net-20060824083440-e278138fb2bc383c
# sha1: 7cf87d86312fd39cd2b37f90c3abefc7302fce36
# inventory sha1: 1456512d6ceaf0debd97a2fe5e8230193d420af4
# parent ids:
# mbp at sourcefrog.net-20060824082026-d539b3b122dc2f2a
# base id: pqm at pqm.ubuntu.com-20060822222325-10c74ceeec1708fc
# properties:
# branch-nick: bzr.mbp.local-transport-tests
# message:
# Change to using LocalURLServer for testing.
#
# We used to run many transport tests three times for different
# LocalServers, but in fact they all end up constructing the same transport.
# So now we just test construction of local transports from urls and paths,
# and run the tests once.
#
# committer: Martin Pool <mbp at sourcefrog.net>
# date: Thu 2006-08-24 18:20:26.174000025 +1000
=== modified file bzrlib/tests/__init__.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy9fX2luaXRfXy5weQorKysgYnpybGliL3Rlc3RzL19faW5pdF9fLnB5
CkBAIC02OSw3ICs2OSw3IEBACiBpbXBvcnQgYnpybGliLnRyYWNlCiBmcm9tIGJ6cmxpYi50cmFu
c3BvcnQgaW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ICAgICAgIHQgPSBnZXRfdHJhbnNwb3J0KGhlcmUpCisgICAgICAgIHNlbGYuYXNzZXJ0SXNJbnN0
YW5jZSh0LCBMb2NhbFRyYW5zcG9ydCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbHModC5iYXNl
LCB1cmx1dGlscy5sb2NhbF9wYXRoX3RvX3VybChoZXJlKSArICcvJykKKworICAgIGRlZiB0ZXN0
X2dldF90cmFuc3BvcnRfZnJvbV9yZWxwYXRoKHNlbGYpOgorICAgICAgICBoZXJlID0gb3MucGF0
aC5hYnNwYXRoKCcuJykKKyAgICAgICAgdCA9IGdldF90cmFuc3BvcnQoJy4nKQorICAgICAgICBz
ZWxmLmFzc2VydElzSW5zdGFuY2UodCwgTG9jYWxUcmFuc3BvcnQpCisgICAgICAgIHNlbGYuYXNz
ZXJ0RXF1YWxzKHQuYmFzZSwgdXJsdXRpbHMubG9jYWxfcGF0aF90b191cmwoaGVyZSkgKyAnLycp
CisKKyAgICBkZWYgdGVzdF9nZXRfdHJhbnNwb3J0X2Zyb21fbG9jYWxfdXJsKHNlbGYpOgorICAg
ICAgICBoZXJlID0gb3MucGF0aC5hYnNwYXRoKCcuJykKKyAgICAgICAgaGVyZV91cmwgPSB1cmx1
dGlscy5sb2NhbF9wYXRoX3RvX3VybChoZXJlKSArICcvJworICAgICAgICB0ID0gZ2V0X3RyYW5z
cG9ydChoZXJlX3VybCkKKyAgICAgICAgc2VsZi5hc3NlcnRJc0luc3RhbmNlKHQsIExvY2FsVHJh
bnNwb3J0KQorICAgICAgICBzZWxmLmFzc2VydEVxdWFscyh0LmJhc2UsIGhlcmVfdXJsKQoK
=== modified file bzrlib/transport/decorator.py // encoding:base64
LS0tIGJ6cmxpYi90cmFuc3BvcnQvZGVjb3JhdG9yLnB5CisrKyBienJsaWIvdHJhbnNwb3J0L2Rl
Y29yYXRvci5weQpAQCAtMTUzLDkgKzE1Myw5IEBACiAgICAgICAgICAgICBzZWxmLl9tYWRlX3Nl
cnZl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
CisgICAgIiIiCiAKICAgICBkZWYgZ2V0X3VybChzZWxmKToKICAgICAgICAgIiIiU2VlIFRyYW5z
cG9ydC5TZXJ2ZXIuZ2V0X3VybC4iIiIKQEAgLTM3MCw3ICszNzQsNiBAQAogCiBkZWYgZ2V0X3Rl
c3RfcGVybXV0YXRpb25zKCk6CiAgICAgIiIiUmV0dXJuIHRoZSBwZXJtdXRhdGlvbnMgdG8gYmUg
dXNlZCBpbiB0ZXN0aW5nLiIiIgotICAgIHJldHVybiBbKExvY2FsVHJhbnNwb3J0LCBMb2NhbFJl
bHBhdGhTZXJ2ZXIpLAotICAgICAgICAgICAgKExvY2FsVHJhbnNwb3J0LCBMb2NhbEFic3BhdGhT
ZXJ2ZXIpLAorICAgIHJldHVybiBbCiAgICAgICAgICAgICAoTG9jYWxUcmFuc3BvcnQsIExvY2Fs
VVJMU2VydmVyKSwKICAgICAgICAgICAgIF0KCg==
# revision id: mbp at sourcefrog.net-20060824082026-d539b3b122dc2f2a
# sha1: 9df407fbabdbe418cdf1fe1d01e3053bc34916e0
# inventory sha1: 8364fd35600373baa1250473fd7d3d62bec4eeff
# parent ids:
# pqm at pqm.ubuntu.com-20060822222325-10c74ceeec1708fc
# properties:
# branch-nick: bzr.mbp.local-transport-tests
--
Martin
More information about the bazaar
mailing list