Merge lp:~vila/bzr/move-test-servers into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~vila/bzr/move-test-servers
Merge into: lp:bzr
Diff against target: 2151 lines (+544/-488)
49 files modified
NEWS (+7/-0)
bzrlib/builtins.py (+5/-4)
bzrlib/smart/server.py (+0/-85)
bzrlib/tests/__init__.py (+18/-13)
bzrlib/tests/blackbox/test_branch.py (+2/-2)
bzrlib/tests/blackbox/test_cat.py (+2/-1)
bzrlib/tests/blackbox/test_info.py (+1/-0)
bzrlib/tests/blackbox/test_push.py (+1/-0)
bzrlib/tests/blackbox/test_selftest.py (+2/-4)
bzrlib/tests/blackbox/test_send.py (+2/-1)
bzrlib/tests/ftp_server/medusa_based.py (+4/-4)
bzrlib/tests/ftp_server/pyftpdlib_based.py (+4/-4)
bzrlib/tests/http_server.py (+4/-2)
bzrlib/tests/per_branch/__init__.py (+8/-13)
bzrlib/tests/per_branch/test_bound_sftp.py (+4/-4)
bzrlib/tests/per_branch/test_branch.py (+2/-2)
bzrlib/tests/per_branch/test_hooks.py (+3/-4)
bzrlib/tests/per_branch/test_http.py (+5/-6)
bzrlib/tests/per_branch/test_push.py (+6/-4)
bzrlib/tests/per_bzrdir/__init__.py (+12/-17)
bzrlib/tests/per_interbranch/test_push.py (+2/-2)
bzrlib/tests/per_pack_repository.py (+5/-6)
bzrlib/tests/per_repository/__init__.py (+12/-17)
bzrlib/tests/per_repository/test_repository.py (+6/-5)
bzrlib/tests/per_repository/test_write_group.py (+6/-3)
bzrlib/tests/per_transport.py (+2/-2)
bzrlib/tests/stub_sftp.py (+4/-4)
bzrlib/tests/test_bzrdir.py (+7/-5)
bzrlib/tests/test_remote.py (+8/-7)
bzrlib/tests/test_repository.py (+0/-1)
bzrlib/tests/test_selftest.py (+11/-13)
bzrlib/tests/test_server.py (+312/-0)
bzrlib/tests/test_smart.py (+6/-6)
bzrlib/tests/test_transport.py (+5/-2)
bzrlib/transport/__init__.py (+1/-28)
bzrlib/transport/brokenrename.py (+4/-11)
bzrlib/transport/chroot.py (+2/-16)
bzrlib/transport/decorator.py (+0/-43)
bzrlib/transport/fakenfs.py (+6/-13)
bzrlib/transport/fakevfat.py (+4/-14)
bzrlib/transport/local.py (+4/-20)
bzrlib/transport/log.py (+6/-20)
bzrlib/transport/memory.py (+10/-9)
bzrlib/transport/nosmart.py (+6/-12)
bzrlib/transport/pathfilter.py (+2/-17)
bzrlib/transport/readonly.py (+6/-14)
bzrlib/transport/remote.py (+2/-2)
bzrlib/transport/trace.py (+7/-13)
bzrlib/transport/unlistable.py (+6/-13)
To merge this branch: bzr merge lp:~vila/bzr/move-test-servers
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+18960@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

This patch moves test servers out of the bzrlib.transport hierarchy
to bzrlib.test.test_server and all related fallouts.

It spun off bug #516183 (testools required for sftp use) to make
sure we don't run into similar problems with other transports.

It's quite big but mostly mechanical.

Given that I relied on the test suite, I don't expect a lot of fallouts.

Some plugins may break if they relied on bzrlib.transport.Server but the fix
will be trivial anyway.

They should be fine if they use our ftp or http servers though.

This patch may be easier to review commit by commit rather than as a whole...

Revision history for this message
John A Meinel (jameinel) wrote :

This change looks ok except:

1) I expect it will cause some significant fallout with Launchpad and possibly some plugins.
2) We should make sure to have a nice big NEWS entry about how to update your code. It looks mostly like just importing 'test_server' and using whatever server you were using previously. (I would expect MemoryServer to be the only one causing problems.)

I wonder if we should just leave in a deprecated thunk for MemoryServer...

3) We should probably try to coordinate with someone like MWH for (1).

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

John A Meinel wrote:
> Review: Approve
> This change looks ok except:
>
> 1) I expect it will cause some significant fallout with Launchpad and possibly some plugins.
> 2) We should make sure to have a nice big NEWS entry about how to update your code. It looks mostly like just importing 'test_server' and using whatever server you were using previously. (I would expect MemoryServer to be the only one causing problems.)
>
> I wonder if we should just leave in a deprecated thunk for MemoryServer...

I think MemoryServer is useful for more than just testing, so I think it should
stay in bzrlib.transport.memory. It's useful for constructing a virtual
filesystem, e.g. Launchpad uses it in non-test code for the automatic bzrdirs
with stacking directives.

This implies to me that the Server base class should remain in bzrlib.transport
too.

Revision history for this message
Robert Collins (lifeless) wrote :

On Wed, 2010-02-10 at 23:51 +0000, Andrew Bennetts wrote:
>
> I think MemoryServer is useful for more than just testing, so I think
> it should
> stay in bzrlib.transport.memory. It's useful for constructing a
> virtual
> filesystem, e.g. Launchpad uses it in non-test code for the automatic
> bzrdirs
> with stacking directives.
>
> This implies to me that the Server base class should remain in
> bzrlib.transport
> too.

I agree with this. I'll go further and say that *most* of our servers
are really quite useful for non-test code. I don't think they should
move under tests at all.

I think the following *should* move under tests:
 - servers that are unsafe to use outside of tests
 - servers that are deliberately broken (and thus their raison d'etre is
for testing)

And these *could* move under tests:
 - the mapping of 'To test transport T use servers A, B and C'

-Rob

Revision history for this message
Martin Pool (mbp) wrote :

On 11 February 2010 12:48, Robert Collins <email address hidden> wrote:
> On Wed, 2010-02-10 at 23:51 +0000, Andrew Bennetts wrote:
>>
>> I think MemoryServer is useful for more than just testing, so I think
>> it should
>> stay in bzrlib.transport.memory.  It's useful for constructing a
>> virtual
>> filesystem, e.g. Launchpad uses it in non-test code for the automatic
>> bzrdirs
>> with stacking directives.
>>
>> This implies to me that the Server base class should remain in
>> bzrlib.transport
>> too.
>
> I agree with this. I'll go further and say that *most* of our servers
> are really quite useful for non-test code.  I don't think they should
> move under tests at all.
>
> I think the following *should* move under tests:
>  - servers that are unsafe to use outside of tests
>  - servers that are deliberately broken (and thus their raison d'etre is
> for testing)
>
> And these *could* move under tests:
>  - the mapping of 'To test transport T use servers A, B and C'

Perhaps we should move them all to bzrlib.servers. Then we can assert
that module is not loaded when it is not needed, and we can allow for
currently limited servers to grow into being more generally useful. I
think we have some intentionally limited transports in b.transport and
I don't see that as essentially problematic. It's more important that
the class name make its limitations clear.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, 2010-02-11 at 01:54 +0000, Martin Pool wrote:
>
>
> Perhaps we should move them all to bzrlib.servers. Then we can assert
> that module is not loaded when it is not needed, and we can allow for
> currently limited servers to grow into being more generally useful. I
> think we have some intentionally limited transports in b.transport and
> I don't see that as essentially problematic. It's more important that
> the class name make its limitations clear.

This sounds fine to me too.

Perhaps bzrlib.transport.servers.* ?

-Rob

Revision history for this message
Martin Pool (mbp) wrote :

On 11 February 2010 13:42, Robert Collins <email address hidden> wrote:
> On Thu, 2010-02-11 at 01:54 +0000, Martin Pool wrote:
>>
>>
>> Perhaps we should move them all to bzrlib.servers.  Then we can assert
>> that module is not loaded when it is not needed, and we can allow for
>> currently limited servers to grow into being more generally useful.  I
>> think we have some intentionally limited transports in b.transport and
>> I don't see that as essentially problematic.  It's more important that
>> the class name make its limitations clear.
>
> This sounds fine to me too.
>
> Perhaps bzrlib.transport.servers.* ?

I'd slightly prefer .servers:

1- submodules seem to occasionally cause more annoying python import
behaviour (circularity etc) than sibling modules
2- bzrlib.transport.servers seems a bit longwinded

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, 2010-02-11 at 02:51 +0000, Martin Pool wrote:
>
> > Perhaps bzrlib.transport.servers.* ?
>
> I'd slightly prefer .servers:
>
> 1- submodules seem to occasionally cause more annoying python import
> behaviour (circularity etc) than sibling modules

Could you enlarge on this? I haven't seen that, unless you mean the
behaviour of 'import foo' in a submodule trying for
'parent.thispackage.foo' first, rather than 'foo.' (the top level foo).
This should be pretty fast after it is tried once, because after that
the dentry cache is hot.

> 2- bzrlib.transport.servers seems a bit longwinded

I proposed transport.servers because:
 - They are specifically transport servers, not smart server servers, or
git servers, or CVS servers; and I wouldn't really want to see a git
server mixed in. I guess we could do servers.transports.*, but thats
equally long winded, and IMO less clear.
 - I see the transport servers as being generally coupled to transports,
not coupled to bzrlib as a whole.

That said, its up to whomever proposes the patch :)

-Rob

Revision history for this message
Martin Pool (mbp) wrote :

On 11 February 2010 14:06, Robert Collins <email address hidden> wrote:
> On Thu, 2010-02-11 at 02:51 +0000, Martin Pool wrote:
>>
>> > Perhaps bzrlib.transport.servers.* ?
>>
>> I'd slightly prefer .servers:
>>
>> 1- submodules seem to occasionally cause more annoying python import
>> behaviour (circularity etc) than sibling modules
>
> Could you enlarge on this? I haven't seen that, unless you mean the
> behaviour of 'import foo' in a submodule trying for
> 'parent.thispackage.foo' first, rather than 'foo.' (the top level foo).
> This should be pretty fast after it is tried once, because after that
> the dentry cache is hot.

You can't do 'import bzrlib.ui.text' in top-level code in 'bzrlib.ui'.

>> 2- bzrlib.transport.servers seems a bit longwinded
>
> I proposed transport.servers because:
>  - They are specifically transport servers, not smart server servers, or
> git servers, or CVS servers; and I wouldn't really want to see a git
> server mixed in. I guess we could do servers.transports.*, but thats
> equally long winded, and IMO less clear.

Are they really? They are things that can be started, stopped, and
that have a URL. Their essentially connection to transports (as
opposed to the fact that they are only used for testing transports)
seems quite weak.

I would be ok with having bzrlib.server.ftp alongside
bzrlib.server.git for example.

>  - I see the transport servers as being generally coupled to transports,
> not coupled to bzrlib as a whole.
>
> That said, its up to whomever proposes the patch :)

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, 2010-02-11 at 03:45 +0000, Martin Pool wrote:
> On 11 February 2010 14:06, Robert Collins <email address hidden> wrote:
> > On Thu, 2010-02-11 at 02:51 +0000, Martin Pool wrote:
> >>
> >> > Perhaps bzrlib.transport.servers.* ?
> >>
> >> I'd slightly prefer .servers:
> >>
> >> 1- submodules seem to occasionally cause more annoying python import
> >> behaviour (circularity etc) than sibling modules
> >
> > Could you enlarge on this? I haven't seen that, unless you mean the
> > behaviour of 'import foo' in a submodule trying for
> > 'parent.thispackage.foo' first, rather than 'foo.' (the top level foo).
> > This should be pretty fast after it is tried once, because after that
> > the dentry cache is hot.
>
> You can't do 'import bzrlib.ui.text' in top-level code in 'bzrlib.ui'.

Thats true. That doesn't seem to apply here though, does it? I don't
think we should shun all subpackages and submodules because that can
happen. In fact, its the case in all imports that you can't import from
within the currently importing package at the top level - this is why
circular imports are a problem. bzrlib.servers seems no more or less
inclined to suffer this than bzrlib.transport.servers, as in neither
case do we seem to have an a-priori need to expose things from within
the namespace.

> >> 2- bzrlib.transport.servers seems a bit longwinded
> >
> > I proposed transport.servers because:
> > - They are specifically transport servers, not smart server servers, or
> > git servers, or CVS servers; and I wouldn't really want to see a git
> > server mixed in. I guess we could do servers.transports.*, but thats
> > equally long winded, and IMO less clear.
>
> Are they really? They are things that can be started, stopped, and
> that have a URL. Their essentially connection to transports (as
> opposed to the fact that they are only used for testing transports)
> seems quite weak.

They are all servers for VFS's, rather than servers for non-FS-like file
systems.

-Rob

Revision history for this message
Vincent Ladeuil (vila) wrote :

Cough, so to clear up a few points:
- bzrlib.transport.Server still exists
- only chroot and pathfilter are really used as servers,
- there is still various grey areas around inheriting from
  b.t.Server or just implementing {start|stop}_server(), and yes
  get_url() is only used for tests,
- I expect most fallouts from LocalUrlServer and to a lesser
  extent MemoryServer (if the bzr code base usage can serve
  as a comparison point),
- given the above, only *tests* should be failing from there.

Also, I first started to deprecate b.t.Server and it helped me
find all obscure usages, but in the end I had to leave it alone to
separate "real" server usages (chroot and pathfilter) from true test
usages. And since a server is just implementing {start|stop}_server()
I already wondered if it wasn't already too much (or said otherwise
a small enough API to not even bother having a base class for it, which
is exactly what smart_server does).

About starting a bzrlib.transport.servers a bzrlib.servers hierarchy:
- YAGNI,
- a slight preference for bzrlib.servers when needed but so far,
  I don't even consider our ftp and http servers like true servers.
  Their intent is to be hacked on to be able to test any crazy
  failure mode. As such, if there is ever a decision needed to be
  made between making them easy to customize or making them faster,
  I will chose the former.

I'll add a NEWS entry explaining the migration path (mostly,
as John said changing an import). Since the fix is trivial,
I don't think we need to make an exception for launchpad
(which may already have other API skews to fix).

Since it has been approved, I'll land that patch which is already
massive and we can improve from there.

Revision history for this message
Vincent Ladeuil (vila) wrote :

I forgot to mention that I've put all test servers into
bzrlib.test.test_server because they looked trivial enough
to not need their own dedicated server.

Semy-arbitrarily I left the ftp and http servers out of that
because they needed a bit more code.

The smart servers for testing for a bit between the two but
they needed to leave the bzrlib.transport hierarchy because
they were intended for *test*.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

...
>>>> 2- bzrlib.transport.servers seems a bit longwinded
>>> I proposed transport.servers because:
>>> - They are specifically transport servers, not smart server servers, or
>>> git servers, or CVS servers; and I wouldn't really want to see a git
>>> server mixed in. I guess we could do servers.transports.*, but thats
>>> equally long winded, and IMO less clear.
>> Are they really? They are things that can be started, stopped, and
>> that have a URL. Their essentially connection to transports (as
>> opposed to the fact that they are only used for testing transports)
>> seems quite weak.
>
> They are all servers for VFS's, rather than servers for non-FS-like file
> systems.
>
> -Rob
>

Just to mention that the whole reason this was brought up at all, is
because the SftpServer implementation depended on something in
'bzrlib.tests' which caused a *runtime* dependency for sftp to require
having 'testtools' installed.

If these servers require 'bzrlib.tests' to be available, that certainly
seems like it belongs as 'test_servers'. (If you can't really use them
without loading the testing infrastructure.)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt0GfgACgkQJdeBCYSNAAN34gCeNGiEfnLScEzhq1cBq0oKY13k
MfYAnifbuaB2Yxa9X84U4yMwIukLDgoA
=asMl
-----END PGP SIGNATURE-----

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

...

> I'll add a NEWS entry explaining the migration path (mostly,
> as John said changing an import). Since the fix is trivial,
> I don't think we need to make an exception for launchpad
> (which may already have other API skews to fix).
>
> Since it has been approved, I'll land that patch which is already
> massive and we can improve from there.
>
>

I would probably make sure to do something about MemoryServer, as that
is likely to actually impact 3rd-party code. The rest can be debated ad
nauseum.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt0GlcACgkQJdeBCYSNAAObkwCfcMuiMwtvY85/vE2RKYQqrNUD
cVQAn1pgkeERuoCCr5PyJpby8t971lLp
=QGYJ
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> "jam" == John A Meinel <email address hidden> writes:

<snip/>

    jam> I would probably make sure to do something about MemoryServer, as that
    jam> is likely to actually impact 3rd-party code. The rest can be debated ad
    jam> nauseum.

I fixed that before landing after discussing it on IRC.

So MemoryServer is still bzrlib.transport.memory if only because
you can't use a Memory Transport without it.

  Vincent

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-02-11 06:15:33 +0000
+++ NEWS 2010-02-11 09:31:16 +0000
@@ -20,6 +20,13 @@
2020
21* ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij)21* ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij)
2222
23* All test servers have been moved out of the bzrlib.transport hierarchy to
24 bzrlib.tests.test_server *except* for MemoryServer, ChrootServer and
25 PathFilteringServer. ``bzrlib`` users may encounter test failures that can
26 be fixed by updating the related imports from ``bzrlib.transport.xxx`` to
27 ``bzrlib.tests.test_server``.
28 (Vincent Ladeuil)
29
23New Features30New Features
24************31************
2532
2633
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-02-11 05:43:31 +0000
+++ bzrlib/builtins.py 2010-02-11 09:31:16 +0000
@@ -54,6 +54,7 @@
54 )54 )
55from bzrlib.branch import Branch55from bzrlib.branch import Branch
56from bzrlib.conflicts import ConflictList56from bzrlib.conflicts import ConflictList
57from bzrlib.transport import memory
57from bzrlib.revisionspec import RevisionSpec, RevisionInfo58from bzrlib.revisionspec import RevisionSpec, RevisionInfo
58from bzrlib.smtp_connection import SMTPConnection59from bzrlib.smtp_connection import SMTPConnection
59from bzrlib.workingtree import WorkingTree60from bzrlib.workingtree import WorkingTree
@@ -3444,11 +3445,11 @@
3444 from bzrlib.tests import stub_sftp3445 from bzrlib.tests import stub_sftp
3445 return stub_sftp.SFTPAbsoluteServer3446 return stub_sftp.SFTPAbsoluteServer
3446 if typestring == "memory":3447 if typestring == "memory":
3447 from bzrlib.transport.memory import MemoryServer3448 from bzrlib.tests import test_server
3448 return MemoryServer3449 return memory.MemoryServer
3449 if typestring == "fakenfs":3450 if typestring == "fakenfs":
3450 from bzrlib.transport.fakenfs import FakeNFSServer3451 from bzrlib.tests import test_server
3451 return FakeNFSServer3452 return test_server.FakeNFSServer
3452 msg = "No known transport type %s. Supported types are: sftp\n" %\3453 msg = "No known transport type %s. Supported types are: sftp\n" %\
3453 (typestring)3454 (typestring)
3454 raise errors.BzrCommandError(msg)3455 raise errors.BzrCommandError(msg)
34553456
=== modified file 'bzrlib/smart/server.py'
--- bzrlib/smart/server.py 2010-01-07 03:03:01 +0000
+++ bzrlib/smart/server.py 2010-02-11 09:31:16 +0000
@@ -236,91 +236,6 @@
236SmartTCPServer.hooks = SmartServerHooks()236SmartTCPServer.hooks = SmartServerHooks()
237237
238238
239class SmartTCPServer_for_testing(SmartTCPServer):
240 """Server suitable for use by transport tests.
241
242 This server is backed by the process's cwd.
243 """
244
245 def __init__(self, thread_name_suffix=''):
246 SmartTCPServer.__init__(self, None)
247 self.client_path_extra = None
248 self.thread_name_suffix = thread_name_suffix
249
250 def get_backing_transport(self, backing_transport_server):
251 """Get a backing transport from a server we are decorating."""
252 return transport.get_transport(backing_transport_server.get_url())
253
254 def start_server(self, backing_transport_server=None,
255 client_path_extra='/extra/'):
256 """Set up server for testing.
257
258 :param backing_transport_server: backing server to use. If not
259 specified, a LocalURLServer at the current working directory will
260 be used.
261 :param client_path_extra: a path segment starting with '/' to append to
262 the root URL for this server. For instance, a value of '/foo/bar/'
263 will mean the root of the backing transport will be published at a
264 URL like `bzr://127.0.0.1:nnnn/foo/bar/`, rather than
265 `bzr://127.0.0.1:nnnn/`. Default value is `extra`, so that tests
266 by default will fail unless they do the necessary path translation.
267 """
268 if not client_path_extra.startswith('/'):
269 raise ValueError(client_path_extra)
270 from bzrlib.transport.chroot import ChrootServer
271 if backing_transport_server is None:
272 from bzrlib.transport.local import LocalURLServer
273 backing_transport_server = LocalURLServer()
274 self.chroot_server = ChrootServer(
275 self.get_backing_transport(backing_transport_server))
276 self.chroot_server.start_server()
277 self.backing_transport = transport.get_transport(
278 self.chroot_server.get_url())
279 self.root_client_path = self.client_path_extra = client_path_extra
280 self.start_background_thread(self.thread_name_suffix)
281
282 def stop_server(self):
283 self.stop_background_thread()
284 self.chroot_server.stop_server()
285
286 def get_url(self):
287 url = super(SmartTCPServer_for_testing, self).get_url()
288 return url[:-1] + self.client_path_extra
289
290 def get_bogus_url(self):
291 """Return a URL which will fail to connect"""
292 return 'bzr://127.0.0.1:1/'
293
294
295class ReadonlySmartTCPServer_for_testing(SmartTCPServer_for_testing):
296 """Get a readonly server for testing."""
297
298 def get_backing_transport(self, backing_transport_server):
299 """Get a backing transport from a server we are decorating."""
300 url = 'readonly+' + backing_transport_server.get_url()
301 return transport.get_transport(url)
302
303
304class SmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing):
305 """A variation of SmartTCPServer_for_testing that limits the client to
306 using RPCs in protocol v2 (i.e. bzr <= 1.5).
307 """
308
309 def get_url(self):
310 url = super(SmartTCPServer_for_testing_v2_only, self).get_url()
311 url = 'bzr-v2://' + url[len('bzr://'):]
312 return url
313
314
315class ReadonlySmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing_v2_only):
316 """Get a readonly server for testing."""
317
318 def get_backing_transport(self, backing_transport_server):
319 """Get a backing transport from a server we are decorating."""
320 url = 'readonly+' + backing_transport_server.get_url()
321 return transport.get_transport(url)
322
323
324def _local_path_for_transport(transport):239def _local_path_for_transport(transport):
325 """Return a local path for transport, if reasonably possible.240 """Return a local path for transport, if reasonably possible.
326 241
327242
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2010-02-11 04:02:41 +0000
+++ bzrlib/tests/__init__.py 2010-02-11 09:31:16 +0000
@@ -101,13 +101,17 @@
101 deprecated_passed,101 deprecated_passed,
102 )102 )
103import bzrlib.trace103import bzrlib.trace
104from bzrlib.transport import get_transport, pathfilter104from bzrlib.transport import (
105 get_transport,
106 memory,
107 pathfilter,
108 )
105import bzrlib.transport109import bzrlib.transport
106from bzrlib.transport.local import LocalURLServer
107from bzrlib.transport.memory import MemoryServer
108from bzrlib.transport.readonly import ReadonlyServer
109from bzrlib.trace import mutter, note110from bzrlib.trace import mutter, note
110from bzrlib.tests import TestUtil111from bzrlib.tests import (
112 test_server,
113 TestUtil,
114 )
111from bzrlib.tests.http_server import HttpServer115from bzrlib.tests.http_server import HttpServer
112from bzrlib.tests.TestUtil import (116from bzrlib.tests.TestUtil import (
113 TestSuite,117 TestSuite,
@@ -124,7 +128,7 @@
124# shown frame is the test code, not our assertXYZ.128# shown frame is the test code, not our assertXYZ.
125__unittest = 1129__unittest = 1
126130
127default_transport = LocalURLServer131default_transport = test_server.LocalURLServer
128132
129133
130_unitialized_attr = object()134_unitialized_attr = object()
@@ -1040,7 +1044,8 @@
1040 if t.base.endswith('/work/'):1044 if t.base.endswith('/work/'):
1041 # we have safety net/test root/work1045 # we have safety net/test root/work
1042 t = t.clone('../..')1046 t = t.clone('../..')
1043 elif isinstance(transport_server, server.SmartTCPServer_for_testing):1047 elif isinstance(transport_server,
1048 test_server.SmartTCPServer_for_testing):
1044 # The smart server adds a path similar to work, which is traversed1049 # The smart server adds a path similar to work, which is traversed
1045 # up from by the client. But the server is chrooted - the actual1050 # up from by the client. But the server is chrooted - the actual
1046 # backing transport is not escaped from, and VFS requests to the1051 # backing transport is not escaped from, and VFS requests to the
@@ -2175,7 +2180,7 @@
2175 if self.__readonly_server is None:2180 if self.__readonly_server is None:
2176 if self.transport_readonly_server is None:2181 if self.transport_readonly_server is None:
2177 # readonly decorator requested2182 # readonly decorator requested
2178 self.__readonly_server = ReadonlyServer()2183 self.__readonly_server = test_server.ReadonlyServer()
2179 else:2184 else:
2180 # explicit readonly transport.2185 # explicit readonly transport.
2181 self.__readonly_server = self.create_transport_readonly_server()2186 self.__readonly_server = self.create_transport_readonly_server()
@@ -2204,7 +2209,7 @@
2204 is no means to override it.2209 is no means to override it.
2205 """2210 """
2206 if self.__vfs_server is None:2211 if self.__vfs_server is None:
2207 self.__vfs_server = MemoryServer()2212 self.__vfs_server = memory.MemoryServer()
2208 self.start_server(self.__vfs_server)2213 self.start_server(self.__vfs_server)
2209 return self.__vfs_server2214 return self.__vfs_server
22102215
@@ -2367,7 +2372,7 @@
2367 return made_control.create_repository(shared=shared)2372 return made_control.create_repository(shared=shared)
23682373
2369 def make_smart_server(self, path):2374 def make_smart_server(self, path):
2370 smart_server = server.SmartTCPServer_for_testing()2375 smart_server = test_server.SmartTCPServer_for_testing()
2371 self.start_server(smart_server, self.get_server())2376 self.start_server(smart_server, self.get_server())
2372 remote_transport = get_transport(smart_server.get_url()).clone(path)2377 remote_transport = get_transport(smart_server.get_url()).clone(path)
2373 return remote_transport2378 return remote_transport
@@ -2400,7 +2405,7 @@
24002405
2401 def setup_smart_server_with_call_log(self):2406 def setup_smart_server_with_call_log(self):
2402 """Sets up a smart server as the transport server with a call log."""2407 """Sets up a smart server as the transport server with a call log."""
2403 self.transport_server = server.SmartTCPServer_for_testing2408 self.transport_server = test_server.SmartTCPServer_for_testing
2404 self.hpss_calls = []2409 self.hpss_calls = []
2405 import traceback2410 import traceback
2406 # Skip the current stack down to the caller of2411 # Skip the current stack down to the caller of
@@ -2619,7 +2624,7 @@
2619 # We can only make working trees locally at the moment. If the2624 # We can only make working trees locally at the moment. If the
2620 # transport can't support them, then we keep the non-disk-backed2625 # transport can't support them, then we keep the non-disk-backed
2621 # branch and create a local checkout.2626 # branch and create a local checkout.
2622 if self.vfs_transport_factory is LocalURLServer:2627 if self.vfs_transport_factory is test_server.LocalURLServer:
2623 # the branch is colocated on disk, we cannot create a checkout.2628 # the branch is colocated on disk, we cannot create a checkout.
2624 # hopefully callers will expect this.2629 # hopefully callers will expect this.
2625 local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))2630 local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))
@@ -2685,7 +2690,7 @@
26852690
2686 def setUp(self):2691 def setUp(self):
2687 super(ChrootedTestCase, self).setUp()2692 super(ChrootedTestCase, self).setUp()
2688 if not self.vfs_transport_factory == MemoryServer:2693 if not self.vfs_transport_factory == memory.MemoryServer:
2689 self.transport_readonly_server = HttpServer2694 self.transport_readonly_server = HttpServer
26902695
26912696
26922697
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- bzrlib/tests/blackbox/test_branch.py 2010-01-12 06:39:06 +0000
+++ bzrlib/tests/blackbox/test_branch.py 2010-02-11 09:31:16 +0000
@@ -31,6 +31,7 @@
31from bzrlib.tests import (31from bzrlib.tests import (
32 KnownFailure,32 KnownFailure,
33 HardlinkFeature,33 HardlinkFeature,
34 test_server,
34 )35 )
35from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer36from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
36from bzrlib.urlutils import local_path_to_url, strip_trailing_slash37from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
@@ -308,8 +309,7 @@
308309
309 def test_branch_stacked_from_smart_server(self):310 def test_branch_stacked_from_smart_server(self):
310 # We can branch stacking on a smart server311 # We can branch stacking on a smart server
311 from bzrlib.smart.server import SmartTCPServer_for_testing312 self.transport_server = test_server.SmartTCPServer_for_testing
312 self.transport_server = SmartTCPServer_for_testing
313 trunk = self.make_branch('mainline', format='1.9')313 trunk = self.make_branch('mainline', format='1.9')
314 out, err = self.run_bzr(314 out, err = self.run_bzr(
315 ['branch', '--stacked', self.get_url('mainline'), 'shallow'])315 ['branch', '--stacked', self.get_url('mainline'), 'shallow'])
316316
=== modified file 'bzrlib/tests/blackbox/test_cat.py'
--- bzrlib/tests/blackbox/test_cat.py 2010-01-12 07:02:54 +0000
+++ bzrlib/tests/blackbox/test_cat.py 2010-02-11 09:31:16 +0000
@@ -22,6 +22,7 @@
22import os22import os
2323
24from bzrlib import tests24from bzrlib import tests
25from bzrlib.transport import memory
2526
2627
27class TestCat(tests.TestCaseWithTransport):28class TestCat(tests.TestCaseWithTransport):
@@ -195,6 +196,6 @@
195 self.assertEqual('contents of README\n', out)196 self.assertEqual('contents of README\n', out)
196197
197 def test_cat_nonexistent_branch(self):198 def test_cat_nonexistent_branch(self):
198 self.vfs_transport_factory = tests.MemoryServer199 self.vfs_transport_factory = memory.MemoryServer
199 self.run_bzr_error(['^bzr: ERROR: Not a branch'],200 self.run_bzr_error(['^bzr: ERROR: Not a branch'],
200 ['cat', self.get_url()])201 ['cat', self.get_url()])
201202
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- bzrlib/tests/blackbox/test_info.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/blackbox/test_info.py 2010-02-11 09:31:16 +0000
@@ -31,6 +31,7 @@
31 )31 )
32from bzrlib.transport import memory32from bzrlib.transport import memory
3333
34
34class TestInfo(tests.TestCaseWithTransport):35class TestInfo(tests.TestCaseWithTransport):
3536
36 def setUp(self):37 def setUp(self):
3738
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- bzrlib/tests/blackbox/test_push.py 2010-01-07 03:03:01 +0000
+++ bzrlib/tests/blackbox/test_push.py 2010-02-11 09:31:16 +0000
@@ -35,6 +35,7 @@
35 blackbox,35 blackbox,
36 http_server,36 http_server,
37 test_foreign,37 test_foreign,
38 test_server,
38 )39 )
39from bzrlib.transport import memory40from bzrlib.transport import memory
4041
4142
=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- bzrlib/tests/blackbox/test_selftest.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/blackbox/test_selftest.py 2010-02-11 09:31:16 +0000
@@ -24,7 +24,7 @@
24 features,24 features,
25 stub_sftp,25 stub_sftp,
26 )26 )
2727from bzrlib.transport import memory
2828
29class SelfTestPatch:29class SelfTestPatch:
3030
@@ -82,10 +82,8 @@
82 def test_transport_set_to_memory(self):82 def test_transport_set_to_memory(self):
83 # Test that we can pass a transport to the selftest core - memory83 # Test that we can pass a transport to the selftest core - memory
84 # version.84 # version.
85 import bzrlib.transport.memory
86 params = self.get_params_passed_to_core('selftest --transport=memory')85 params = self.get_params_passed_to_core('selftest --transport=memory')
87 self.assertEqual(bzrlib.transport.memory.MemoryServer,86 self.assertEqual(memory.MemoryServer, params[1]["transport"])
88 params[1]["transport"])
8987
90 def test_parameters_passed_to_core(self):88 def test_parameters_passed_to_core(self):
91 params = self.get_params_passed_to_core('selftest --list-only')89 params = self.get_params_passed_to_core('selftest --list-only')
9290
=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- bzrlib/tests/blackbox/test_send.py 2009-11-28 00:48:03 +0000
+++ bzrlib/tests/blackbox/test_send.py 2010-02-11 09:31:16 +0000
@@ -26,6 +26,7 @@
26 tests,26 tests,
27 )27 )
28from bzrlib.bundle import serializer28from bzrlib.bundle import serializer
29from bzrlib.transport import memory
2930
3031
31def load_tests(standard_tests, module, loader):32def load_tests(standard_tests, module, loader):
@@ -280,7 +281,7 @@
280 self.assertEqual('rev3', md.revision_id)281 self.assertEqual('rev3', md.revision_id)
281282
282 def test_nonexistant_branch(self):283 def test_nonexistant_branch(self):
283 self.vfs_transport_factory = tests.MemoryServer284 self.vfs_transport_factory = memory.MemoryServer
284 location = self.get_url('absentdir/')285 location = self.get_url('absentdir/')
285 out, err = self.run_bzr(["send", "--from", location], retcode=3)286 out, err = self.run_bzr(["send", "--from", location], retcode=3)
286 self.assertEqual(out, '')287 self.assertEqual(out, '')
287288
=== modified file 'bzrlib/tests/ftp_server/medusa_based.py'
--- bzrlib/tests/ftp_server/medusa_based.py 2010-01-08 03:35:09 +0000
+++ bzrlib/tests/ftp_server/medusa_based.py 2010-02-11 09:31:16 +0000
@@ -33,8 +33,8 @@
33from bzrlib import (33from bzrlib import (
34 tests,34 tests,
35 trace,35 trace,
36 transport,
37 )36 )
37from bzrlib.tests import test_server
3838
3939
40class test_filesystem(medusa.filesys.os_filesystem):40class test_filesystem(medusa.filesys.os_filesystem):
@@ -210,7 +210,7 @@
210 trace.mutter('ftp_server %s: %s', type, message)210 trace.mutter('ftp_server %s: %s', type, message)
211211
212212
213class FTPTestServer(transport.Server):213class FTPTestServer(test_server.TestServer):
214 """Common code for FTP server facilities."""214 """Common code for FTP server facilities."""
215215
216 no_unicode_support = True216 no_unicode_support = True
@@ -236,8 +236,8 @@
236 self.logs.append(message)236 self.logs.append(message)
237237
238 def start_server(self, vfs_server=None):238 def start_server(self, vfs_server=None):
239 from bzrlib.transport.local import LocalURLServer239 if not (vfs_server is None or isinstance(vfs_server,
240 if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):240 test_server.LocalURLServer)):
241 raise AssertionError(241 raise AssertionError(
242 "FTPServer currently assumes local transport, got %s" % vfs_server)242 "FTPServer currently assumes local transport, got %s" % vfs_server)
243 self._root = os.getcwdu()243 self._root = os.getcwdu()
244244
=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-01-13 15:30:22 +0000
+++ bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-02-11 09:31:16 +0000
@@ -29,8 +29,8 @@
29from bzrlib import (29from bzrlib import (
30 osutils,30 osutils,
31 trace,31 trace,
32 transport,
33 )32 )
33from bzrlib.tests import test_server
3434
3535
36class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):36class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):
@@ -133,7 +133,7 @@
133 self.addr = self.socket.getsockname()133 self.addr = self.socket.getsockname()
134134
135135
136class FTPTestServer(transport.Server):136class FTPTestServer(test_server.TestServer):
137 """Common code for FTP server facilities."""137 """Common code for FTP server facilities."""
138138
139 def __init__(self):139 def __init__(self):
@@ -158,8 +158,8 @@
158 self.logs.append(message)158 self.logs.append(message)
159159
160 def start_server(self, vfs_server=None):160 def start_server(self, vfs_server=None):
161 from bzrlib.transport.local import LocalURLServer161 if not (vfs_server is None or isinstance(vfs_server,
162 if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):162 test_server.LocalURLServer)):
163 raise AssertionError(163 raise AssertionError(
164 "FTPServer currently assumes local transport, got %s"164 "FTPServer currently assumes local transport, got %s"
165 % vfs_server)165 % vfs_server)
166166
=== modified file 'bzrlib/tests/http_server.py'
--- bzrlib/tests/http_server.py 2010-01-07 03:03:01 +0000
+++ bzrlib/tests/http_server.py 2010-02-11 09:31:16 +0000
@@ -31,6 +31,7 @@
31import urlparse31import urlparse
3232
33from bzrlib import transport33from bzrlib import transport
34from bzrlib.tests import test_server
34from bzrlib.transport import local35from bzrlib.transport import local
3536
3637
@@ -530,8 +531,9 @@
530 """531 """
531 # XXX: TODO: make the server back onto vfs_server rather than local532 # XXX: TODO: make the server back onto vfs_server rather than local
532 # disk.533 # disk.
533 if not (backing_transport_server is None or \534 if not (backing_transport_server is None
534 isinstance(backing_transport_server, local.LocalURLServer)):535 or isinstance(backing_transport_server,
536 test_server.LocalURLServer)):
535 raise AssertionError(537 raise AssertionError(
536 "HTTPServer currently assumes local transport, got %s" % \538 "HTTPServer currently assumes local transport, got %s" % \
537 backing_transport_server)539 backing_transport_server)
538540
=== modified file 'bzrlib/tests/per_branch/__init__.py'
--- bzrlib/tests/per_branch/__init__.py 2009-08-17 06:17:21 +0000
+++ bzrlib/tests/per_branch/__init__.py 2010-02-11 09:31:16 +0000
@@ -32,14 +32,9 @@
32 _legacy_formats,32 _legacy_formats,
33 )33 )
34from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat34from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
35from bzrlib.smart.server import (35from bzrlib.tests import test_server
36 ReadonlySmartTCPServer_for_testing,
37 ReadonlySmartTCPServer_for_testing_v2_only,
38 SmartTCPServer_for_testing,
39 SmartTCPServer_for_testing_v2_only,
40 )
41from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir36from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
42from bzrlib.transport.memory import MemoryServer37from bzrlib.transport import memory
4338
4439
45def make_scenarios(transport_server, transport_readonly_server,40def make_scenarios(transport_server, transport_readonly_server,
@@ -148,18 +143,18 @@
148 # Add RemoteBranch tests, which need a special server.143 # Add RemoteBranch tests, which need a special server.
149 remote_branch_format = RemoteBranchFormat()144 remote_branch_format = RemoteBranchFormat()
150 scenarios.extend(make_scenarios(145 scenarios.extend(make_scenarios(
151 SmartTCPServer_for_testing,146 test_server.SmartTCPServer_for_testing,
152 ReadonlySmartTCPServer_for_testing,147 test_server.ReadonlySmartTCPServer_for_testing,
153 [(remote_branch_format, remote_branch_format._matchingbzrdir)],148 [(remote_branch_format, remote_branch_format._matchingbzrdir)],
154 MemoryServer,149 memory.MemoryServer,
155 name_suffix='-default'))150 name_suffix='-default'))
156 # Also add tests for RemoteBranch with HPSS protocol v2 (i.e. bzr <1.6)151 # Also add tests for RemoteBranch with HPSS protocol v2 (i.e. bzr <1.6)
157 # server.152 # server.
158 scenarios.extend(make_scenarios(153 scenarios.extend(make_scenarios(
159 SmartTCPServer_for_testing_v2_only,154 test_server.SmartTCPServer_for_testing_v2_only,
160 ReadonlySmartTCPServer_for_testing_v2_only,155 test_server.ReadonlySmartTCPServer_for_testing_v2_only,
161 [(remote_branch_format, remote_branch_format._matchingbzrdir)],156 [(remote_branch_format, remote_branch_format._matchingbzrdir)],
162 MemoryServer,157 memory.MemoryServer,
163 name_suffix='-v2'))158 name_suffix='-v2'))
164 return scenarios159 return scenarios
165160
166161
=== modified file 'bzrlib/tests/per_branch/test_bound_sftp.py'
--- bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-11 09:31:16 +0000
@@ -25,16 +25,16 @@
25 errors,25 errors,
26 tests,26 tests,
27 )27 )
28from bzrlib.transport.local import LocalURLServer28from bzrlib.tests import test_server
29from bzrlib.transport.memory import MemoryServer29from bzrlib.transport import memory
3030
3131
32class BoundSFTPBranch(tests.TestCaseWithTransport):32class BoundSFTPBranch(tests.TestCaseWithTransport):
3333
34 def setUp(self):34 def setUp(self):
35 tests.TestCaseWithTransport.setUp(self)35 tests.TestCaseWithTransport.setUp(self)
36 self.vfs_transport_factory = MemoryServer36 self.vfs_transport_factory = memory.MemoryServer
37 if self.transport_server is LocalURLServer:37 if self.transport_server is test_server.LocalURLServer:
38 self.transport_server = None38 self.transport_server = None
3939
40 def create_branches(self):40 def create_branches(self):
4141
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- bzrlib/tests/per_branch/test_branch.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_branch.py 2010-02-11 09:31:16 +0000
@@ -37,7 +37,7 @@
37 per_branch,37 per_branch,
38 )38 )
39from bzrlib.tests.http_server import HttpServer39from bzrlib.tests.http_server import HttpServer
40from bzrlib.transport.memory import MemoryServer40from bzrlib.transport import memory
4141
4242
43class TestTestCaseWithBranch(per_branch.TestCaseWithBranch):43class TestTestCaseWithBranch(per_branch.TestCaseWithBranch):
@@ -512,7 +512,7 @@
512512
513 def setUp(self):513 def setUp(self):
514 super(ChrootedTests, self).setUp()514 super(ChrootedTests, self).setUp()
515 if not self.vfs_transport_factory == MemoryServer:515 if not self.vfs_transport_factory == memory.MemoryServer:
516 self.transport_readonly_server = HttpServer516 self.transport_readonly_server = HttpServer
517517
518 def test_open_containing(self):518 def test_open_containing(self):
519519
=== modified file 'bzrlib/tests/per_branch/test_hooks.py'
--- bzrlib/tests/per_branch/test_hooks.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_hooks.py 2010-02-11 09:31:16 +0000
@@ -23,8 +23,7 @@
23 revision,23 revision,
24 tests,24 tests,
25 )25 )
26from bzrlib.smart import server26from bzrlib.tests import test_server
27
2827
29class ChangeBranchTipTestCase(tests.TestCaseWithMemoryTransport):28class ChangeBranchTipTestCase(tests.TestCaseWithMemoryTransport):
30 """Base TestCase for testing pre/post_change_branch_tip hooks."""29 """Base TestCase for testing pre/post_change_branch_tip hooks."""
@@ -151,8 +150,8 @@
151 b = self.make_branch('.')150 b = self.make_branch('.')
152 if isinstance(b, remote.RemoteBranch):151 if isinstance(b, remote.RemoteBranch):
153 # RemoteBranch creation:152 # RemoteBranch creation:
154 if (self.transport_readonly_server ==153 if (self.transport_readonly_server
155 server.ReadonlySmartTCPServer_for_testing_v2_only):154 == test_server.ReadonlySmartTCPServer_for_testing_v2_only):
156 # Older servers:155 # Older servers:
157 self.assertEqual(3, len(self.hook_calls))156 self.assertEqual(3, len(self.hook_calls))
158 # creates the branch via the VFS (for older servers)157 # creates the branch via the VFS (for older servers)
159158
=== modified file 'bzrlib/tests/per_branch/test_http.py'
--- bzrlib/tests/per_branch/test_http.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_http.py 2010-02-11 09:31:16 +0000
@@ -20,10 +20,9 @@
20 branch,20 branch,
21 errors,21 errors,
22 )22 )
23from bzrlib.tests import per_branch23from bzrlib.tests import (
24from bzrlib.transport import (24 per_branch,
25 chroot,25 test_server,
26 local,
27 )26 )
2827
2928
@@ -38,8 +37,8 @@
3837
39 def setUp(self):38 def setUp(self):
40 super(InaccessibleParentTests, self).setUp()39 super(InaccessibleParentTests, self).setUp()
41 if self.transport_server in (local.LocalURLServer, None):40 if self.transport_server in (test_server.LocalURLServer, None):
42 self.transport_readonly_server = chroot.TestingChrootServer41 self.transport_readonly_server = test_server.TestingChrootServer
4342
44 def get_branch_with_invalid_parent(self):43 def get_branch_with_invalid_parent(self):
45 """Get a branch whose get_parent will raise InaccessibleParent."""44 """Get a branch whose get_parent will raise InaccessibleParent."""
4645
=== modified file 'bzrlib/tests/per_branch/test_push.py'
--- bzrlib/tests/per_branch/test_push.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_push.py 2010-02-11 09:31:16 +0000
@@ -38,8 +38,10 @@
38 server,38 server,
39 repository as _mod_smart_repo,39 repository as _mod_smart_repo,
40 )40 )
41from bzrlib.tests import per_branch41from bzrlib.tests import (
42from bzrlib.transport import local42 per_branch,
43 test_server,
44 )
4345
4446
45class TestPush(per_branch.TestCaseWithBranch):47class TestPush(per_branch.TestCaseWithBranch):
@@ -149,7 +151,7 @@
149 try:151 try:
150 tree = a_branch.bzrdir.create_workingtree()152 tree = a_branch.bzrdir.create_workingtree()
151 except errors.NotLocalUrl:153 except errors.NotLocalUrl:
152 if self.vfs_transport_factory is local.LocalURLServer:154 if self.vfs_transport_factory is test_server.LocalURLServer:
153 # the branch is colocated on disk, we cannot create a checkout.155 # the branch is colocated on disk, we cannot create a checkout.
154 # hopefully callers will expect this.156 # hopefully callers will expect this.
155 local_controldir= bzrdir.BzrDir.open(157 local_controldir= bzrdir.BzrDir.open(
@@ -391,7 +393,7 @@
391 super(EmptyPushSmartEffortTests, self).setUp()393 super(EmptyPushSmartEffortTests, self).setUp()
392 # Create a smart server that publishes whatever the backing VFS server394 # Create a smart server that publishes whatever the backing VFS server
393 # does.395 # does.
394 self.smart_server = server.SmartTCPServer_for_testing()396 self.smart_server = test_server.SmartTCPServer_for_testing()
395 self.start_server(self.smart_server, self.get_server())397 self.start_server(self.smart_server, self.get_server())
396 # Make two empty branches, 'empty' and 'target'.398 # Make two empty branches, 'empty' and 'target'.
397 self.empty_branch = self.make_branch('empty')399 self.empty_branch = self.make_branch('empty')
398400
=== modified file 'bzrlib/tests/per_bzrdir/__init__.py'
--- bzrlib/tests/per_bzrdir/__init__.py 2009-07-10 06:45:04 +0000
+++ bzrlib/tests/per_bzrdir/__init__.py 2010-02-11 09:31:16 +0000
@@ -26,11 +26,12 @@
2626
27from bzrlib.bzrdir import BzrDirFormat27from bzrlib.bzrdir import BzrDirFormat
28from bzrlib.tests import (28from bzrlib.tests import (
29 default_transport,29 default_transport,
30 multiply_tests,30 multiply_tests,
31 TestCaseWithTransport,31 test_server,
32 )32 TestCaseWithTransport,
33from bzrlib.transport.memory import MemoryServer33 )
34from bzrlib.transport import memory
3435
3536
36def make_scenarios(vfs_factory, transport_server, transport_readonly_server,37def make_scenarios(vfs_factory, transport_server, transport_readonly_server,
@@ -88,26 +89,20 @@
88 None,89 None,
89 formats)90 formats)
90 # This will always add scenarios using the smart server.91 # This will always add scenarios using the smart server.
91 from bzrlib.smart.server import (
92 ReadonlySmartTCPServer_for_testing,
93 ReadonlySmartTCPServer_for_testing_v2_only,
94 SmartTCPServer_for_testing,
95 SmartTCPServer_for_testing_v2_only,
96 )
97 from bzrlib.remote import RemoteBzrDirFormat92 from bzrlib.remote import RemoteBzrDirFormat
98 # test the remote server behaviour when backed with a MemoryTransport93 # test the remote server behaviour when backed with a MemoryTransport
99 # Once for the current version94 # Once for the current version
100 scenarios.extend(make_scenarios(95 scenarios.extend(make_scenarios(
101 MemoryServer,96 memory.MemoryServer,
102 SmartTCPServer_for_testing,97 test_server.SmartTCPServer_for_testing,
103 ReadonlySmartTCPServer_for_testing,98 test_server.ReadonlySmartTCPServer_for_testing,
104 [(RemoteBzrDirFormat())],99 [(RemoteBzrDirFormat())],
105 name_suffix='-default'))100 name_suffix='-default'))
106 # And once with < 1.6 - the 'v2' protocol.101 # And once with < 1.6 - the 'v2' protocol.
107 scenarios.extend(make_scenarios(102 scenarios.extend(make_scenarios(
108 MemoryServer,103 memory.MemoryServer,
109 SmartTCPServer_for_testing_v2_only,104 test_server.SmartTCPServer_for_testing_v2_only,
110 ReadonlySmartTCPServer_for_testing_v2_only,105 test_server.ReadonlySmartTCPServer_for_testing_v2_only,
111 [(RemoteBzrDirFormat())],106 [(RemoteBzrDirFormat())],
112 name_suffix='-v2'))107 name_suffix='-v2'))
113 # add the tests for the sub modules108 # add the tests for the sub modules
114109
=== modified file 'bzrlib/tests/per_interbranch/test_push.py'
--- bzrlib/tests/per_interbranch/test_push.py 2010-01-25 17:48:22 +0000
+++ bzrlib/tests/per_interbranch/test_push.py 2010-02-11 09:31:16 +0000
@@ -40,7 +40,7 @@
40 TestCaseWithInterBranch,40 TestCaseWithInterBranch,
41 )41 )
42from bzrlib.transport import get_transport42from bzrlib.transport import get_transport
43from bzrlib.transport.local import LocalURLServer43from bzrlib.tests import test_server
4444
4545
46# These tests are based on similar tests in 46# These tests are based on similar tests in
@@ -155,7 +155,7 @@
155 try:155 try:
156 tree = a_branch.bzrdir.create_workingtree()156 tree = a_branch.bzrdir.create_workingtree()
157 except errors.NotLocalUrl:157 except errors.NotLocalUrl:
158 if self.vfs_transport_factory is LocalURLServer:158 if self.vfs_transport_factory is test_server.LocalURLServer:
159 # the branch is colocated on disk, we cannot create a checkout.159 # the branch is colocated on disk, we cannot create a checkout.
160 # hopefully callers will expect this.160 # hopefully callers will expect this.
161 local_controldir = bzrdir.BzrDir.open(self.get_vfs_only_url('repo/tree'))161 local_controldir = bzrdir.BzrDir.open(self.get_vfs_only_url('repo/tree'))
162162
=== modified file 'bzrlib/tests/per_pack_repository.py'
--- bzrlib/tests/per_pack_repository.py 2010-01-25 17:48:22 +0000
+++ bzrlib/tests/per_pack_repository.py 2010-02-11 09:31:16 +0000
@@ -45,7 +45,6 @@
45from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a45from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
46from bzrlib.smart import (46from bzrlib.smart import (
47 client,47 client,
48 server,
49 )48 )
50from bzrlib.tests import (49from bzrlib.tests import (
51 TestCase,50 TestCase,
@@ -54,10 +53,10 @@
54 TestSkipped,53 TestSkipped,
55 )54 )
56from bzrlib.transport import (55from bzrlib.transport import (
57 fakenfs,56 get_transport,
58 memory,57 memory,
59 get_transport,
60 )58 )
59from bzrlib.tests import test_server
61from bzrlib.tests.per_repository import TestCaseWithRepository60from bzrlib.tests.per_repository import TestCaseWithRepository
6261
6362
@@ -240,7 +239,7 @@
240239
241 def test_commit_write_group_returns_new_pack_names(self):240 def test_commit_write_group_returns_new_pack_names(self):
242 # This test doesn't need real disk.241 # This test doesn't need real disk.
243 self.vfs_transport_factory = tests.MemoryServer242 self.vfs_transport_factory = memory.MemoryServer
244 format = self.get_format()243 format = self.get_format()
245 repo = self.make_repository('foo', format=format)244 repo = self.make_repository('foo', format=format)
246 repo.lock_write()245 repo.lock_write()
@@ -277,7 +276,7 @@
277 def test_fail_obsolete_deletion(self):276 def test_fail_obsolete_deletion(self):
278 # failing to delete obsolete packs is not fatal277 # failing to delete obsolete packs is not fatal
279 format = self.get_format()278 format = self.get_format()
280 server = fakenfs.FakeNFSServer()279 server = test_server.FakeNFSServer()
281 self.start_server(server)280 self.start_server(server)
282 transport = get_transport(server.get_url())281 transport = get_transport(server.get_url())
283 bzrdir = self.get_format().initialize_on_transport(transport)282 bzrdir = self.get_format().initialize_on_transport(transport)
@@ -1068,7 +1067,7 @@
1068 super(TestSmartServerAutopack, self).setUp()1067 super(TestSmartServerAutopack, self).setUp()
1069 # Create a smart server that publishes whatever the backing VFS server1068 # Create a smart server that publishes whatever the backing VFS server
1070 # does.1069 # does.
1071 self.smart_server = server.SmartTCPServer_for_testing()1070 self.smart_server = test_server.SmartTCPServer_for_testing()
1072 self.start_server(self.smart_server, self.get_server())1071 self.start_server(self.smart_server, self.get_server())
1073 # Log all HPSS calls into self.hpss_calls.1072 # Log all HPSS calls into self.hpss_calls.
1074 client._SmartClient.hooks.install_named_hook(1073 client._SmartClient.hooks.install_named_hook(
10751074
=== modified file 'bzrlib/tests/per_repository/__init__.py'
--- bzrlib/tests/per_repository/__init__.py 2009-07-22 17:22:06 +0000
+++ bzrlib/tests/per_repository/__init__.py 2010-02-11 09:31:16 +0000
@@ -32,19 +32,14 @@
32 weaverepo,32 weaverepo,
33 )33 )
34from bzrlib.remote import RemoteBzrDirFormat, RemoteRepositoryFormat34from bzrlib.remote import RemoteBzrDirFormat, RemoteRepositoryFormat
35from bzrlib.smart.server import (
36 ReadonlySmartTCPServer_for_testing,
37 ReadonlySmartTCPServer_for_testing_v2_only,
38 SmartTCPServer_for_testing,
39 SmartTCPServer_for_testing_v2_only,
40 )
41from bzrlib.tests import (35from bzrlib.tests import (
42 default_transport,36 default_transport,
43 multiply_scenarios,37 multiply_scenarios,
44 multiply_tests,38 multiply_tests,
45 )39 test_server,
40 )
46from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir41from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
47from bzrlib.transport.memory import MemoryServer42from bzrlib.transport import memory
4843
4944
50def formats_to_scenarios(formats, transport_server, transport_readonly_server,45def formats_to_scenarios(formats, transport_server, transport_readonly_server,
@@ -91,14 +86,14 @@
91 None)86 None)
92 format_scenarios.extend(formats_to_scenarios(87 format_scenarios.extend(formats_to_scenarios(
93 [('-default', RemoteRepositoryFormat())],88 [('-default', RemoteRepositoryFormat())],
94 SmartTCPServer_for_testing,89 test_server.SmartTCPServer_for_testing,
95 ReadonlySmartTCPServer_for_testing,90 test_server.ReadonlySmartTCPServer_for_testing,
96 MemoryServer))91 memory.MemoryServer))
97 format_scenarios.extend(formats_to_scenarios(92 format_scenarios.extend(formats_to_scenarios(
98 [('-v2', RemoteRepositoryFormat())],93 [('-v2', RemoteRepositoryFormat())],
99 SmartTCPServer_for_testing_v2_only,94 test_server.SmartTCPServer_for_testing_v2_only,
100 ReadonlySmartTCPServer_for_testing_v2_only,95 test_server.ReadonlySmartTCPServer_for_testing_v2_only,
101 MemoryServer))96 memory.MemoryServer))
102 return format_scenarios97 return format_scenarios
10398
10499
105100
=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- bzrlib/tests/per_repository/test_repository.py 2010-02-10 19:20:57 +0000
+++ bzrlib/tests/per_repository/test_repository.py 2010-02-11 09:31:16 +0000
@@ -43,9 +43,10 @@
43 pack_repo,43 pack_repo,
44 weaverepo,44 weaverepo,
45 )45 )
46from bzrlib.smart import server46from bzrlib.tests import (
47from bzrlib.tests import per_repository47 per_repository,
48from bzrlib.transport.fakevfat import FakeVFATServer48 test_server,
49 )
4950
5051
51class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository):52class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository):
@@ -823,7 +824,7 @@
823 """Make a RemoteRepository object backed by a real repository that will824 """Make a RemoteRepository object backed by a real repository that will
824 be created at the given path."""825 be created at the given path."""
825 repo = self.make_repository(path, shared=shared)826 repo = self.make_repository(path, shared=shared)
826 smart_server = server.SmartTCPServer_for_testing()827 smart_server = test_server.SmartTCPServer_for_testing()
827 self.start_server(smart_server, self.get_server())828 self.start_server(smart_server, self.get_server())
828 remote_transport = transport.get_transport(829 remote_transport = transport.get_transport(
829 smart_server.get_url()).clone(path)830 smart_server.get_url()).clone(path)
@@ -1295,7 +1296,7 @@
1295 # about local disk layout/support.1296 # about local disk layout/support.
1296 if isinstance(self.repository_format, remote.RemoteRepositoryFormat):1297 if isinstance(self.repository_format, remote.RemoteRepositoryFormat):
1297 return1298 return
1298 self.transport_server = FakeVFATServer1299 self.transport_server = test_server.FakeVFATServer
1299 FOO_ID = 'foo<:>ID'1300 FOO_ID = 'foo<:>ID'
1300 REV_ID = 'revid-1'1301 REV_ID = 'revid-1'
1301 # this makes a default format repository always, which is wrong:1302 # this makes a default format repository always, which is wrong:
13021303
=== modified file 'bzrlib/tests/per_repository/test_write_group.py'
--- bzrlib/tests/per_repository/test_write_group.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_repository/test_write_group.py 2010-02-11 09:31:16 +0000
@@ -29,8 +29,11 @@
29 tests,29 tests,
30 versionedfile,30 versionedfile,
31 )31 )
32from bzrlib.transport import local, memory32from bzrlib.tests import (
33from bzrlib.tests import per_repository33 per_repository,
34 test_server,
35 )
36from bzrlib.transport import memory
3437
3538
36class TestWriteGroup(per_repository.TestCaseWithRepository):39class TestWriteGroup(per_repository.TestCaseWithRepository):
@@ -114,7 +117,7 @@
114 repo.unlock()117 repo.unlock()
115118
116 def test_abort_write_group_does_not_raise_when_suppressed(self):119 def test_abort_write_group_does_not_raise_when_suppressed(self):
117 if self.transport_server is local.LocalURLServer:120 if self.transport_server is test_server.LocalURLServer:
118 self.transport_server = None121 self.transport_server = None
119 self.vfs_transport_factory = memory.MemoryServer122 self.vfs_transport_factory = memory.MemoryServer
120 repo = self.make_repository('repo')123 repo = self.make_repository('repo')
121124
=== modified file 'bzrlib/tests/per_transport.py'
--- bzrlib/tests/per_transport.py 2010-01-07 16:27:12 +0000
+++ bzrlib/tests/per_transport.py 2010-02-11 09:31:16 +0000
@@ -52,6 +52,7 @@
52 TestNotApplicable,52 TestNotApplicable,
53 multiply_tests,53 multiply_tests,
54 )54 )
55from bzrlib.tests import test_server
55from bzrlib.tests.test_transport import TestTransportImplementation56from bzrlib.tests.test_transport import TestTransportImplementation
56from bzrlib.transport import (57from bzrlib.transport import (
57 ConnectedTransport,58 ConnectedTransport,
@@ -170,8 +171,7 @@
170 self.assertEqual(True, t.has_any(['b', 'b', 'b']))171 self.assertEqual(True, t.has_any(['b', 'b', 'b']))
171172
172 def test_has_root_works(self):173 def test_has_root_works(self):
173 from bzrlib.smart import server174 if self.transport_server is test_server.SmartTCPServer_for_testing:
174 if self.transport_server is server.SmartTCPServer_for_testing:
175 raise TestNotApplicable(175 raise TestNotApplicable(
176 "SmartTCPServer_for_testing intentionally does not allow "176 "SmartTCPServer_for_testing intentionally does not allow "
177 "access to /.")177 "access to /.")
178178
=== modified file 'bzrlib/tests/stub_sftp.py'
--- bzrlib/tests/stub_sftp.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/stub_sftp.py 2010-02-11 09:31:16 +0000
@@ -33,10 +33,10 @@
33 urlutils,33 urlutils,
34 )34 )
35from bzrlib.transport import (35from bzrlib.transport import (
36 local,
37 Server,
38 ssh,36 ssh,
39 )37 )
38from bzrlib.tests import test_server
39
4040
41class StubServer (paramiko.ServerInterface):41class StubServer (paramiko.ServerInterface):
4242
@@ -382,7 +382,7 @@
382 return bytes_sent382 return bytes_sent
383383
384384
385class SFTPServer(Server):385class SFTPServer(test_server.TestServer):
386 """Common code for SFTP server facilities."""386 """Common code for SFTP server facilities."""
387387
388 def __init__(self, server_interface=StubServer):388 def __init__(self, server_interface=StubServer):
@@ -436,7 +436,7 @@
436 # XXX: TODO: make sftpserver back onto backing_server rather than local436 # XXX: TODO: make sftpserver back onto backing_server rather than local
437 # disk.437 # disk.
438 if not (backing_server is None or438 if not (backing_server is None or
439 isinstance(backing_server, local.LocalURLServer)):439 isinstance(backing_server, test_server.LocalURLServer)):
440 raise AssertionError(440 raise AssertionError(
441 "backing_server should not be %r, because this can only serve the "441 "backing_server should not be %r, because this can only serve the "
442 "local current working directory." % (backing_server,))442 "local current working directory." % (backing_server,))
443443
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- bzrlib/tests/test_bzrdir.py 2010-01-08 07:34:31 +0000
+++ bzrlib/tests/test_bzrdir.py 2010-02-11 09:31:16 +0000
@@ -50,9 +50,11 @@
50 http_utils,50 http_utils,
51 )51 )
52from bzrlib.tests.test_http import TestWithTransport_pycurl52from bzrlib.tests.test_http import TestWithTransport_pycurl
53from bzrlib.transport import get_transport53from bzrlib.transport import (
54 get_transport,
55 memory,
56 )
54from bzrlib.transport.http._urllib import HttpTransport_urllib57from bzrlib.transport.http._urllib import HttpTransport_urllib
55from bzrlib.transport.memory import MemoryServer
56from bzrlib.transport.nosmart import NoSmartTransportDecorator58from bzrlib.transport.nosmart import NoSmartTransportDecorator
57from bzrlib.transport.readonly import ReadonlyTransportDecorator59from bzrlib.transport.readonly import ReadonlyTransportDecorator
58from bzrlib.repofmt import knitrepo, weaverepo, pack_repo60from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
@@ -354,7 +356,7 @@
354356
355 def test_create_branch_convenience_root(self):357 def test_create_branch_convenience_root(self):
356 """Creating a branch at the root of a fs should work."""358 """Creating a branch at the root of a fs should work."""
357 self.vfs_transport_factory = MemoryServer359 self.vfs_transport_factory = memory.MemoryServer
358 # outside a repo the default convenience output is a repo+branch_tree360 # outside a repo the default convenience output is a repo+branch_tree
359 format = bzrdir.format_registry.make_bzrdir('knit')361 format = bzrdir.format_registry.make_bzrdir('knit')
360 branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),362 branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
@@ -565,7 +567,7 @@
565567
566 def setUp(self):568 def setUp(self):
567 super(ChrootedTests, self).setUp()569 super(ChrootedTests, self).setUp()
568 if not self.vfs_transport_factory == MemoryServer:570 if not self.vfs_transport_factory == memory.MemoryServer:
569 self.transport_readonly_server = http_server.HttpServer571 self.transport_readonly_server = http_server.HttpServer
570572
571 def local_branch_path(self, branch):573 def local_branch_path(self, branch):
@@ -1049,7 +1051,7 @@
10491051
1050 def setUp(self):1052 def setUp(self):
1051 super(NonLocalTests, self).setUp()1053 super(NonLocalTests, self).setUp()
1052 self.vfs_transport_factory = MemoryServer1054 self.vfs_transport_factory = memory.MemoryServer
10531055
1054 def test_create_branch_convenience(self):1056 def test_create_branch_convenience(self):
1055 # outside a repo the default convenience output is a repo+branch_tree1057 # outside a repo the default convenience output is a repo+branch_tree
10561058
=== modified file 'bzrlib/tests/test_remote.py'
--- bzrlib/tests/test_remote.py 2010-01-25 17:48:22 +0000
+++ bzrlib/tests/test_remote.py 2010-02-11 09:31:16 +0000
@@ -54,13 +54,14 @@
54 )54 )
55from bzrlib.repofmt import groupcompress_repo, pack_repo55from bzrlib.repofmt import groupcompress_repo, pack_repo
56from bzrlib.revision import NULL_REVISION56from bzrlib.revision import NULL_REVISION
57from bzrlib.smart import server, medium57from bzrlib.smart import medium
58from bzrlib.smart.client import _SmartClient58from bzrlib.smart.client import _SmartClient
59from bzrlib.smart.repository import SmartServerRepositoryGetParentMap59from bzrlib.smart.repository import SmartServerRepositoryGetParentMap
60from bzrlib.tests import (60from bzrlib.tests import (
61 condition_isinstance,61 condition_isinstance,
62 split_suite_by_condition,62 split_suite_by_condition,
63 multiply_tests,63 multiply_tests,
64 test_server,
64 )65 )
65from bzrlib.transport import get_transport66from bzrlib.transport import get_transport
66from bzrlib.transport.memory import MemoryTransport67from bzrlib.transport.memory import MemoryTransport
@@ -75,9 +76,9 @@
75 standard_tests, condition_isinstance(BasicRemoteObjectTests))76 standard_tests, condition_isinstance(BasicRemoteObjectTests))
76 smart_server_version_scenarios = [77 smart_server_version_scenarios = [
77 ('HPSS-v2',78 ('HPSS-v2',
78 {'transport_server': server.SmartTCPServer_for_testing_v2_only}),79 {'transport_server': test_server.SmartTCPServer_for_testing_v2_only}),
79 ('HPSS-v3',80 ('HPSS-v3',
80 {'transport_server': server.SmartTCPServer_for_testing})]81 {'transport_server': test_server.SmartTCPServer_for_testing})]
81 return multiply_tests(to_adapt, smart_server_version_scenarios, result)82 return multiply_tests(to_adapt, smart_server_version_scenarios, result)
8283
8384
@@ -2074,7 +2075,7 @@
20742075
2075 def test_allows_new_revisions(self):2076 def test_allows_new_revisions(self):
2076 """get_parent_map's results can be updated by commit."""2077 """get_parent_map's results can be updated by commit."""
2077 smart_server = server.SmartTCPServer_for_testing()2078 smart_server = test_server.SmartTCPServer_for_testing()
2078 self.start_server(smart_server)2079 self.start_server(smart_server)
2079 self.make_branch('branch')2080 self.make_branch('branch')
2080 branch = Branch.open(smart_server.get_url() + '/branch')2081 branch = Branch.open(smart_server.get_url() + '/branch')
@@ -2622,7 +2623,7 @@
2622 """RemoteRepository.copy_content_into optimizations"""2623 """RemoteRepository.copy_content_into optimizations"""
26232624
2624 def test_copy_content_remote_to_local(self):2625 def test_copy_content_remote_to_local(self):
2625 self.transport_server = server.SmartTCPServer_for_testing2626 self.transport_server = test_server.SmartTCPServer_for_testing
2626 src_repo = self.make_repository('repo1')2627 src_repo = self.make_repository('repo1')
2627 src_repo = repository.Repository.open(self.get_url('repo1'))2628 src_repo = repository.Repository.open(self.get_url('repo1'))
2628 # At the moment the tarball-based copy_content_into can't write back2629 # At the moment the tarball-based copy_content_into can't write back
@@ -2941,7 +2942,7 @@
2941 stacked_branch = self.make_branch('stacked', format='1.9')2942 stacked_branch = self.make_branch('stacked', format='1.9')
2942 stacked_branch.set_stacked_on_url('../base')2943 stacked_branch.set_stacked_on_url('../base')
2943 # start a server looking at this2944 # start a server looking at this
2944 smart_server = server.SmartTCPServer_for_testing()2945 smart_server = test_server.SmartTCPServer_for_testing()
2945 self.start_server(smart_server)2946 self.start_server(smart_server)
2946 remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked')2947 remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked')
2947 # can get its branch and repository2948 # can get its branch and repository
@@ -3103,7 +3104,7 @@
3103 super(TestRemoteBranchEffort, self).setUp()3104 super(TestRemoteBranchEffort, self).setUp()
3104 # Create a smart server that publishes whatever the backing VFS server3105 # Create a smart server that publishes whatever the backing VFS server
3105 # does.3106 # does.
3106 self.smart_server = server.SmartTCPServer_for_testing()3107 self.smart_server = test_server.SmartTCPServer_for_testing()
3107 self.start_server(self.smart_server, self.get_server())3108 self.start_server(self.smart_server, self.get_server())
3108 # Log all HPSS calls into self.hpss_calls.3109 # Log all HPSS calls into self.hpss_calls.
3109 _SmartClient.hooks.install_named_hook(3110 _SmartClient.hooks.install_named_hook(
31103111
=== modified file 'bzrlib/tests/test_repository.py'
--- bzrlib/tests/test_repository.py 2010-01-31 12:10:40 +0000
+++ bzrlib/tests/test_repository.py 2010-02-11 09:31:16 +0000
@@ -51,7 +51,6 @@
51 fakenfs,51 fakenfs,
52 get_transport,52 get_transport,
53 )53 )
54from bzrlib.transport.memory import MemoryServer
55from bzrlib import (54from bzrlib import (
56 bencode,55 bencode,
57 bzrdir,56 bzrdir,
5857
=== modified file 'bzrlib/tests/test_selftest.py'
--- bzrlib/tests/test_selftest.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/test_selftest.py 2010-02-11 09:31:16 +0000
@@ -64,11 +64,12 @@
64 features,64 features,
65 stub_sftp,65 stub_sftp,
66 test_lsprof,66 test_lsprof,
67 test_server,
67 test_sftp_transport,68 test_sftp_transport,
68 TestUtil,69 TestUtil,
69 )70 )
70from bzrlib.trace import note71from bzrlib.trace import note
71from bzrlib.transport.memory import MemoryServer, MemoryTransport72from bzrlib.transport import memory
72from bzrlib.version import _get_bzr_source_tree73from bzrlib.version import _get_bzr_source_tree
7374
7475
@@ -622,9 +623,8 @@
622623
623 def test_get_readonly_url_none(self):624 def test_get_readonly_url_none(self):
624 from bzrlib.transport import get_transport625 from bzrlib.transport import get_transport
625 from bzrlib.transport.memory import MemoryServer
626 from bzrlib.transport.readonly import ReadonlyTransportDecorator626 from bzrlib.transport.readonly import ReadonlyTransportDecorator
627 self.vfs_transport_factory = MemoryServer627 self.vfs_transport_factory = memory.MemoryServer
628 self.transport_readonly_server = None628 self.transport_readonly_server = None
629 # calling get_readonly_transport() constructs a decorator on the url629 # calling get_readonly_transport() constructs a decorator on the url
630 # for the server630 # for the server
@@ -639,9 +639,8 @@
639 def test_get_readonly_url_http(self):639 def test_get_readonly_url_http(self):
640 from bzrlib.tests.http_server import HttpServer640 from bzrlib.tests.http_server import HttpServer
641 from bzrlib.transport import get_transport641 from bzrlib.transport import get_transport
642 from bzrlib.transport.local import LocalURLServer
643 from bzrlib.transport.http import HttpTransportBase642 from bzrlib.transport.http import HttpTransportBase
644 self.transport_server = LocalURLServer643 self.transport_server = test_server.LocalURLServer
645 self.transport_readonly_server = HttpServer644 self.transport_readonly_server = HttpServer
646 # calling get_readonly_transport() gives us a HTTP server instance.645 # calling get_readonly_transport() gives us a HTTP server instance.
647 url = self.get_readonly_url()646 url = self.get_readonly_url()
@@ -678,13 +677,13 @@
678677
679 def setUp(self):678 def setUp(self):
680 super(TestTestCaseTransports, self).setUp()679 super(TestTestCaseTransports, self).setUp()
681 self.vfs_transport_factory = MemoryServer680 self.vfs_transport_factory = memory.MemoryServer
682681
683 def test_make_bzrdir_preserves_transport(self):682 def test_make_bzrdir_preserves_transport(self):
684 t = self.get_transport()683 t = self.get_transport()
685 result_bzrdir = self.make_bzrdir('subdir')684 result_bzrdir = self.make_bzrdir('subdir')
686 self.assertIsInstance(result_bzrdir.transport,685 self.assertIsInstance(result_bzrdir.transport,
687 MemoryTransport)686 memory.MemoryTransport)
688 # should not be on disk, should only be in memory687 # should not be on disk, should only be in memory
689 self.failIfExists('subdir')688 self.failIfExists('subdir')
690689
@@ -1470,7 +1469,7 @@
1470 # permitted.1469 # permitted.
1471 # Manually set one up (TestCase doesn't and shouldn't provide magic1470 # Manually set one up (TestCase doesn't and shouldn't provide magic
1472 # machinery)1471 # machinery)
1473 transport_server = MemoryServer()1472 transport_server = memory.MemoryServer()
1474 transport_server.start_server()1473 transport_server.start_server()
1475 self.addCleanup(transport_server.stop_server)1474 self.addCleanup(transport_server.stop_server)
1476 t = transport.get_transport(transport_server.get_url())1475 t = transport.get_transport(transport_server.get_url())
@@ -1558,7 +1557,7 @@
1558 result.calls)1557 result.calls)
15591558
1560 def test_start_server_registers_url(self):1559 def test_start_server_registers_url(self):
1561 transport_server = MemoryServer()1560 transport_server = memory.MemoryServer()
1562 # A little strict, but unlikely to be changed soon.1561 # A little strict, but unlikely to be changed soon.
1563 self.assertEqual([], self._bzr_selftest_roots)1562 self.assertEqual([], self._bzr_selftest_roots)
1564 self.start_server(transport_server)1563 self.start_server(transport_server)
@@ -1805,8 +1804,7 @@
1805 # make_branch_and_tree has to use local branch and repositories1804 # make_branch_and_tree has to use local branch and repositories
1806 # when the vfs transport and local disk are colocated, even if1805 # when the vfs transport and local disk are colocated, even if
1807 # a different transport is in use for url generation.1806 # a different transport is in use for url generation.
1808 from bzrlib.transport.fakevfat import FakeVFATServer1807 self.transport_server = test_server.FakeVFATServer
1809 self.transport_server = FakeVFATServer
1810 self.assertFalse(self.get_url('t1').startswith('file://'))1808 self.assertFalse(self.get_url('t1').startswith('file://'))
1811 tree = self.make_branch_and_tree('t1')1809 tree = self.make_branch_and_tree('t1')
1812 base = tree.bzrdir.root_transport.base1810 base = tree.bzrdir.root_transport.base
@@ -1952,7 +1950,7 @@
1952 self.check_transport_set(stub_sftp.SFTPAbsoluteServer)1950 self.check_transport_set(stub_sftp.SFTPAbsoluteServer)
19531951
1954 def test_transport_memory(self):1952 def test_transport_memory(self):
1955 self.check_transport_set(bzrlib.transport.memory.MemoryServer)1953 self.check_transport_set(memory.MemoryServer)
19561954
19571955
1958class TestSelftestWithIdList(tests.TestCaseInTempDir, SelfTestHelper):1956class TestSelftestWithIdList(tests.TestCaseInTempDir, SelfTestHelper):
@@ -2623,7 +2621,7 @@
2623 # Running bzr in blackbox mode, normal/expected/user errors should be2621 # Running bzr in blackbox mode, normal/expected/user errors should be
2624 # caught in the regular way and turned into an error message plus exit2622 # caught in the regular way and turned into an error message plus exit
2625 # code.2623 # code.
2626 transport_server = MemoryServer()2624 transport_server = memory.MemoryServer()
2627 transport_server.start_server()2625 transport_server.start_server()
2628 self.addCleanup(transport_server.stop_server)2626 self.addCleanup(transport_server.stop_server)
2629 url = transport_server.get_url()2627 url = transport_server.get_url()
26302628
=== added file 'bzrlib/tests/test_server.py'
--- bzrlib/tests/test_server.py 1970-01-01 00:00:00 +0000
+++ bzrlib/tests/test_server.py 2010-02-11 09:31:16 +0000
@@ -0,0 +1,312 @@
1# Copyright (C) 2005, 2006, 2007, 2008, 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17from bzrlib import (
18 transport,
19 urlutils,
20 )
21from bzrlib.transport import (
22 chroot,
23 pathfilter,
24 )
25from bzrlib.smart import server
26
27
28class TestServer(transport.Server):
29 """A Transport Server dedicated to tests.
30
31 The TestServer interface provides a server for a given transport. We use
32 these servers as loopback testing tools. For any given transport the
33 Servers it provides must either allow writing, or serve the contents
34 of os.getcwdu() at the time start_server is called.
35
36 Note that these are real servers - they must implement all the things
37 that we want bzr transports to take advantage of.
38 """
39
40 def get_url(self):
41 """Return a url for this server.
42
43 If the transport does not represent a disk directory (i.e. it is
44 a database like svn, or a memory only transport, it should return
45 a connection to a newly established resource for this Server.
46 Otherwise it should return a url that will provide access to the path
47 that was os.getcwdu() when start_server() was called.
48
49 Subsequent calls will return the same resource.
50 """
51 raise NotImplementedError
52
53 def get_bogus_url(self):
54 """Return a url for this protocol, that will fail to connect.
55
56 This may raise NotImplementedError to indicate that this server cannot
57 provide bogus urls.
58 """
59 raise NotImplementedError
60
61
62class LocalURLServer(TestServer):
63 """A pretend server for local transports, using file:// urls.
64
65 Of course no actual server is required to access the local filesystem, so
66 this just exists to tell the test code how to get to it.
67 """
68
69 def start_server(self):
70 pass
71
72 def get_url(self):
73 """See Transport.Server.get_url."""
74 return urlutils.local_path_to_url('')
75
76
77class DecoratorServer(TestServer):
78 """Server for the TransportDecorator for testing with.
79
80 To use this when subclassing TransportDecorator, override override the
81 get_decorator_class method.
82 """
83
84 def start_server(self, server=None):
85 """See bzrlib.transport.Server.start_server.
86
87 :server: decorate the urls given by server. If not provided a
88 LocalServer is created.
89 """
90 if server is not None:
91 self._made_server = False
92 self._server = server
93 else:
94 self._made_server = True
95 self._server = LocalURLServer()
96 self._server.start_server()
97
98 def stop_server(self):
99 if self._made_server:
100 self._server.stop_server()
101
102 def get_decorator_class(self):
103 """Return the class of the decorators we should be constructing."""
104 raise NotImplementedError(self.get_decorator_class)
105
106 def get_url_prefix(self):
107 """What URL prefix does this decorator produce?"""
108 return self.get_decorator_class()._get_url_prefix()
109
110 def get_bogus_url(self):
111 """See bzrlib.transport.Server.get_bogus_url."""
112 return self.get_url_prefix() + self._server.get_bogus_url()
113
114 def get_url(self):
115 """See bzrlib.transport.Server.get_url."""
116 return self.get_url_prefix() + self._server.get_url()
117
118
119class BrokenRenameServer(DecoratorServer):
120 """Server for the BrokenRenameTransportDecorator for testing with."""
121
122 def get_decorator_class(self):
123 from bzrlib.transport import brokenrename
124 return brokenrename.BrokenRenameTransportDecorator
125
126
127class FakeNFSServer(DecoratorServer):
128 """Server for the FakeNFSTransportDecorator for testing with."""
129
130 def get_decorator_class(self):
131 from bzrlib.transport import fakenfs
132 return fakenfs.FakeNFSTransportDecorator
133
134
135class FakeVFATServer(DecoratorServer):
136 """A server that suggests connections through FakeVFATTransportDecorator
137
138 For use in testing.
139 """
140
141 def get_decorator_class(self):
142 from bzrlib.transport import fakevfat
143 return fakevfat.FakeVFATTransportDecorator
144
145
146class LogDecoratorServer(DecoratorServer):
147 """Server for testing."""
148
149 def get_decorator_class(self):
150 from bzrlib.transport import log
151 return log.TransportLogDecorator
152
153
154class NoSmartTransportServer(DecoratorServer):
155 """Server for the NoSmartTransportDecorator for testing with."""
156
157 def get_decorator_class(self):
158 from bzrlib.transport import nosmart
159 return nosmart.NoSmartTransportDecorator
160
161
162class ReadonlyServer(DecoratorServer):
163 """Server for the ReadonlyTransportDecorator for testing with."""
164
165 def get_decorator_class(self):
166 from bzrlib.transport import readonly
167 return readonly.ReadonlyTransportDecorator
168
169
170class TraceServer(DecoratorServer):
171 """Server for the TransportTraceDecorator for testing with."""
172
173 def get_decorator_class(self):
174 from bzrlib.transport import trace
175 return trace.TransportTraceDecorator
176
177
178class UnlistableServer(DecoratorServer):
179 """Server for the UnlistableTransportDecorator for testing with."""
180
181 def get_decorator_class(self):
182 from bzrlib.transport import unlistable
183 return unlistable.UnlistableTransportDecorator
184
185
186class TestingPathFilteringServer(pathfilter.PathFilteringServer):
187
188 def __init__(self):
189 """TestingPathFilteringServer is not usable until start_server
190 is called."""
191
192 def start_server(self, backing_server=None):
193 """Setup the Chroot on backing_server."""
194 if backing_server is not None:
195 self.backing_transport = transport.get_transport(
196 backing_server.get_url())
197 else:
198 self.backing_transport = transport.get_transport('.')
199 self.backing_transport.clone('added-by-filter').ensure_base()
200 self.filter_func = lambda x: 'added-by-filter/' + x
201 super(TestingPathFilteringServer, self).start_server()
202
203 def get_bogus_url(self):
204 raise NotImplementedError
205
206
207class TestingChrootServer(chroot.ChrootServer):
208
209 def __init__(self):
210 """TestingChrootServer is not usable until start_server is called."""
211 super(TestingChrootServer, self).__init__(None)
212
213 def start_server(self, backing_server=None):
214 """Setup the Chroot on backing_server."""
215 if backing_server is not None:
216 self.backing_transport = transport.get_transport(
217 backing_server.get_url())
218 else:
219 self.backing_transport = transport.get_transport('.')
220 super(TestingChrootServer, self).start_server()
221
222 def get_bogus_url(self):
223 raise NotImplementedError
224
225
226class SmartTCPServer_for_testing(server.SmartTCPServer):
227 """Server suitable for use by transport tests.
228
229 This server is backed by the process's cwd.
230 """
231
232 def __init__(self, thread_name_suffix=''):
233 super(SmartTCPServer_for_testing, self).__init__(None)
234 self.client_path_extra = None
235 self.thread_name_suffix = thread_name_suffix
236
237 def get_backing_transport(self, backing_transport_server):
238 """Get a backing transport from a server we are decorating."""
239 return transport.get_transport(backing_transport_server.get_url())
240
241 def start_server(self, backing_transport_server=None,
242 client_path_extra='/extra/'):
243 """Set up server for testing.
244
245 :param backing_transport_server: backing server to use. If not
246 specified, a LocalURLServer at the current working directory will
247 be used.
248 :param client_path_extra: a path segment starting with '/' to append to
249 the root URL for this server. For instance, a value of '/foo/bar/'
250 will mean the root of the backing transport will be published at a
251 URL like `bzr://127.0.0.1:nnnn/foo/bar/`, rather than
252 `bzr://127.0.0.1:nnnn/`. Default value is `extra`, so that tests
253 by default will fail unless they do the necessary path translation.
254 """
255 if not client_path_extra.startswith('/'):
256 raise ValueError(client_path_extra)
257 from bzrlib.transport.chroot import ChrootServer
258 if backing_transport_server is None:
259 backing_transport_server = LocalURLServer()
260 self.chroot_server = ChrootServer(
261 self.get_backing_transport(backing_transport_server))
262 self.chroot_server.start_server()
263 self.backing_transport = transport.get_transport(
264 self.chroot_server.get_url())
265 self.root_client_path = self.client_path_extra = client_path_extra
266 self.start_background_thread(self.thread_name_suffix)
267
268 def stop_server(self):
269 self.stop_background_thread()
270 self.chroot_server.stop_server()
271
272 def get_url(self):
273 url = super(SmartTCPServer_for_testing, self).get_url()
274 return url[:-1] + self.client_path_extra
275
276 def get_bogus_url(self):
277 """Return a URL which will fail to connect"""
278 return 'bzr://127.0.0.1:1/'
279
280
281class ReadonlySmartTCPServer_for_testing(SmartTCPServer_for_testing):
282 """Get a readonly server for testing."""
283
284 def get_backing_transport(self, backing_transport_server):
285 """Get a backing transport from a server we are decorating."""
286 url = 'readonly+' + backing_transport_server.get_url()
287 return transport.get_transport(url)
288
289
290class SmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing):
291 """A variation of SmartTCPServer_for_testing that limits the client to
292 using RPCs in protocol v2 (i.e. bzr <= 1.5).
293 """
294
295 def get_url(self):
296 url = super(SmartTCPServer_for_testing_v2_only, self).get_url()
297 url = 'bzr-v2://' + url[len('bzr://'):]
298 return url
299
300
301class ReadonlySmartTCPServer_for_testing_v2_only(
302 SmartTCPServer_for_testing_v2_only):
303 """Get a readonly server for testing."""
304
305 def get_backing_transport(self, backing_transport_server):
306 """Get a backing transport from a server we are decorating."""
307 url = 'readonly+' + backing_transport_server.get_url()
308 return transport.get_transport(url)
309
310
311
312
0313
=== modified file 'bzrlib/tests/test_smart.py'
--- bzrlib/tests/test_smart.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/test_smart.py 2010-02-11 09:31:16 +0000
@@ -48,9 +48,9 @@
48 server,48 server,
49 vfs,49 vfs,
50 )50 )
51from bzrlib.tests import test_server
51from bzrlib.transport import (52from bzrlib.transport import (
52 chroot,53 chroot,
53 local,
54 memory,54 memory,
55 )55 )
5656
@@ -106,7 +106,7 @@
106 self.transport_server = self.make_transport_server106 self.transport_server = self.make_transport_server
107107
108 def make_transport_server(self):108 def make_transport_server(self):
109 return server.SmartTCPServer_for_testing('-' + self.id())109 return test_server.SmartTCPServer_for_testing('-' + self.id())
110110
111 def get_smart_medium(self):111 def get_smart_medium(self):
112 """Get a smart medium to use in tests."""112 """Get a smart medium to use in tests."""
@@ -489,7 +489,7 @@
489class TestSmartServerRequestOpenBzrDir_2_1_disk(TestCaseWithChrootedTransport):489class TestSmartServerRequestOpenBzrDir_2_1_disk(TestCaseWithChrootedTransport):
490490
491 def test_present_with_workingtree(self):491 def test_present_with_workingtree(self):
492 self.vfs_transport_factory = local.LocalURLServer492 self.vfs_transport_factory = test_server.LocalURLServer
493 backing = self.get_transport()493 backing = self.get_transport()
494 request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing)494 request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing)
495 bd = self.make_bzrdir('.')495 bd = self.make_bzrdir('.')
@@ -520,7 +520,7 @@
520520
521 def test_branch_reference(self):521 def test_branch_reference(self):
522 """When there is a branch reference, the reference URL is returned."""522 """When there is a branch reference, the reference URL is returned."""
523 self.vfs_transport_factory = local.LocalURLServer523 self.vfs_transport_factory = test_server.LocalURLServer
524 backing = self.get_transport()524 backing = self.get_transport()
525 request = smart_dir.SmartServerRequestOpenBranch(backing)525 request = smart_dir.SmartServerRequestOpenBranch(backing)
526 branch = self.make_branch('branch')526 branch = self.make_branch('branch')
@@ -561,7 +561,7 @@
561561
562 def test_branch_reference(self):562 def test_branch_reference(self):
563 """When there is a branch reference, the reference URL is returned."""563 """When there is a branch reference, the reference URL is returned."""
564 self.vfs_transport_factory = local.LocalURLServer564 self.vfs_transport_factory = test_server.LocalURLServer
565 backing = self.get_transport()565 backing = self.get_transport()
566 request = smart_dir.SmartServerRequestOpenBranchV2(backing)566 request = smart_dir.SmartServerRequestOpenBranchV2(backing)
567 branch = self.make_branch('branch')567 branch = self.make_branch('branch')
@@ -624,7 +624,7 @@
624624
625 def test_branch_reference(self):625 def test_branch_reference(self):
626 """When there is a branch reference, the reference URL is returned."""626 """When there is a branch reference, the reference URL is returned."""
627 self.vfs_transport_factory = local.LocalURLServer627 self.vfs_transport_factory = test_server.LocalURLServer
628 backing = self.get_transport()628 backing = self.get_transport()
629 request = smart_dir.SmartServerRequestOpenBranchV3(backing)629 request = smart_dir.SmartServerRequestOpenBranchV3(backing)
630 branch = self.make_branch('branch')630 branch = self.make_branch('branch')
631631
=== modified file 'bzrlib/tests/test_transport.py'
--- bzrlib/tests/test_transport.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/test_transport.py 2010-02-11 09:31:16 +0000
@@ -36,7 +36,10 @@
36 pathfilter,36 pathfilter,
37 readonly,37 readonly,
38 )38 )
39from bzrlib.tests import features39from bzrlib.tests import (
40 features,
41 test_server,
42 )
4043
4144
42# TODO: Should possibly split transport-specific tests into their own files.45# TODO: Should possibly split transport-specific tests into their own files.
@@ -593,7 +596,7 @@
593596
594 def test_fakenfs_server_default(self):597 def test_fakenfs_server_default(self):
595 # a FakeNFSServer() should bring up a local relpath server for itself598 # a FakeNFSServer() should bring up a local relpath server for itself
596 server = fakenfs.FakeNFSServer()599 server = test_server.FakeNFSServer()
597 self.start_server(server)600 self.start_server(server)
598 # the url should be decorated appropriately601 # the url should be decorated appropriately
599 self.assertStartsWith(server.get_url(), 'fakenfs+')602 self.assertStartsWith(server.get_url(), 'fakenfs+')
600603
=== modified file 'bzrlib/transport/__init__.py'
--- bzrlib/transport/__init__.py 2010-01-07 03:03:01 +0000
+++ bzrlib/transport/__init__.py 2010-02-11 09:31:16 +0000
@@ -1663,13 +1663,7 @@
1663class Server(object):1663class Server(object):
1664 """A Transport Server.1664 """A Transport Server.
16651665
1666 The Server interface provides a server for a given transport. We use1666 The Server interface provides a server for a given transport type.
1667 these servers as loopback testing tools. For any given transport the
1668 Servers it provides must either allow writing, or serve the contents
1669 of os.getcwdu() at the time start_server is called.
1670
1671 Note that these are real servers - they must implement all the things
1672 that we want bzr transports to take advantage of.
1673 """1667 """
16741668
1675 def start_server(self):1669 def start_server(self):
@@ -1678,27 +1672,6 @@
1678 def stop_server(self):1672 def stop_server(self):
1679 """Remove the server and cleanup any resources it owns."""1673 """Remove the server and cleanup any resources it owns."""
16801674
1681 def get_url(self):
1682 """Return a url for this server.
1683
1684 If the transport does not represent a disk directory (i.e. it is
1685 a database like svn, or a memory only transport, it should return
1686 a connection to a newly established resource for this Server.
1687 Otherwise it should return a url that will provide access to the path
1688 that was os.getcwdu() when start_server() was called.
1689
1690 Subsequent calls will return the same resource.
1691 """
1692 raise NotImplementedError
1693
1694 def get_bogus_url(self):
1695 """Return a url for this protocol, that will fail to connect.
1696
1697 This may raise NotImplementedError to indicate that this server cannot
1698 provide bogus urls.
1699 """
1700 raise NotImplementedError
1701
17021675
1703# None is the default transport, for things with no url scheme1676# None is the default transport, for things with no url scheme
1704register_transport_proto('file://',1677register_transport_proto('file://',
17051678
=== modified file 'bzrlib/transport/brokenrename.py'
--- bzrlib/transport/brokenrename.py 2009-03-23 14:59:43 +0000
+++ bzrlib/transport/brokenrename.py 2010-02-11 09:31:16 +0000
@@ -23,10 +23,10 @@
23 errors,23 errors,
24 urlutils,24 urlutils,
25 )25 )
26from bzrlib.transport.decorator import TransportDecorator, DecoratorServer26from bzrlib.transport import decorator
2727
2828
29class BrokenRenameTransportDecorator(TransportDecorator):29class BrokenRenameTransportDecorator(decorator.TransportDecorator):
30 """A transport that fails to detect clashing renames"""30 """A transport that fails to detect clashing renames"""
3131
32 @classmethod32 @classmethod
@@ -46,13 +46,6 @@
46 return46 return
4747
4848
49class BrokenRenameServer(DecoratorServer):
50 """Server for the BrokenRenameTransportDecorator for testing with."""
51
52 def get_decorator_class(self):
53 return BrokenRenameTransportDecorator
54
55
56def get_test_permutations():49def get_test_permutations():
57 """Return the permutations to be used in testing."""50 """Return the permutations to be used in testing."""
58 # we don't use this for general testing, only for the tests that51 # we don't use this for general testing, only for the tests that
5952
=== modified file 'bzrlib/transport/chroot.py'
--- bzrlib/transport/chroot.py 2010-01-07 03:03:01 +0000
+++ bzrlib/transport/chroot.py 2010-02-11 09:31:16 +0000
@@ -65,21 +65,7 @@
65 return self._relpath_from_server_root(relpath)65 return self._relpath_from_server_root(relpath)
6666
6767
68class TestingChrootServer(ChrootServer):
69
70 def __init__(self):
71 """TestingChrootServer is not usable until start_server is called."""
72 ChrootServer.__init__(self, None)
73
74 def start_server(self, backing_server=None):
75 """Setup the Chroot on backing_server."""
76 if backing_server is not None:
77 self.backing_transport = get_transport(backing_server.get_url())
78 else:
79 self.backing_transport = get_transport('.')
80 ChrootServer.start_server(self)
81
82
83def get_test_permutations():68def get_test_permutations():
84 """Return the permutations to be used in testing."""69 """Return the permutations to be used in testing."""
85 return [(ChrootTransport, TestingChrootServer)]70 from bzrlib.tests import test_server
71 return [(ChrootTransport, test_server.TestingChrootServer)]
8672
=== modified file 'bzrlib/transport/decorator.py'
--- bzrlib/transport/decorator.py 2010-01-07 03:03:01 +0000
+++ bzrlib/transport/decorator.py 2010-02-11 09:31:16 +0000
@@ -177,49 +177,6 @@
177 return None177 return None
178178
179179
180class DecoratorServer(Server):
181 """Server for the TransportDecorator for testing with.
182
183 To use this when subclassing TransportDecorator, override override the
184 get_decorator_class method.
185 """
186
187 def start_server(self, server=None):
188 """See bzrlib.transport.Server.start_server.
189
190 :server: decorate the urls given by server. If not provided a
191 LocalServer is created.
192 """
193 if server is not None:
194 self._made_server = False
195 self._server = server
196 else:
197 from bzrlib.transport.local import LocalURLServer
198 self._made_server = True
199 self._server = LocalURLServer()
200 self._server.start_server()
201
202 def stop_server(self):
203 if self._made_server:
204 self._server.stop_server()
205
206 def get_decorator_class(self):
207 """Return the class of the decorators we should be constructing."""
208 raise NotImplementedError(self.get_decorator_class)
209
210 def get_url_prefix(self):
211 """What URL prefix does this decorator produce?"""
212 return self.get_decorator_class()._get_url_prefix()
213
214 def get_bogus_url(self):
215 """See bzrlib.transport.Server.get_bogus_url."""
216 return self.get_url_prefix() + self._server.get_bogus_url()
217
218 def get_url(self):
219 """See bzrlib.transport.Server.get_url."""
220 return self.get_url_prefix() + self._server.get_url()
221
222
223def get_test_permutations():180def get_test_permutations():
224 """Return the permutations to be used in testing.181 """Return the permutations to be used in testing.
225182
226183
=== modified file 'bzrlib/transport/fakenfs.py'
--- bzrlib/transport/fakenfs.py 2009-03-23 14:59:43 +0000
+++ bzrlib/transport/fakenfs.py 2010-02-11 09:31:16 +0000
@@ -28,10 +28,10 @@
28 errors,28 errors,
29 urlutils,29 urlutils,
30 )30 )
31from bzrlib.transport.decorator import TransportDecorator, DecoratorServer31from bzrlib.transport import decorator
3232
3333
34class FakeNFSTransportDecorator(TransportDecorator):34class FakeNFSTransportDecorator(decorator.TransportDecorator):
35 """A transport that behaves like NFS, for testing"""35 """A transport that behaves like NFS, for testing"""
3636
37 @classmethod37 @classmethod
@@ -62,14 +62,7 @@
62 return self._decorated.delete(relpath)62 return self._decorated.delete(relpath)
6363
6464
65class FakeNFSServer(DecoratorServer):
66 """Server for the FakeNFSTransportDecorator for testing with."""
67
68 def get_decorator_class(self):
69 return FakeNFSTransportDecorator
70
71
72def get_test_permutations():65def get_test_permutations():
73 """Return the permutations to be used in testing."""66 """Return the permutations to be used in testing."""
74 return [(FakeNFSTransportDecorator, FakeNFSServer),67 from bzrlib.tests import test_server
75 ]68 return [(FakeNFSTransportDecorator, test_server.FakeNFSServer),]
7669
=== modified file 'bzrlib/transport/fakevfat.py'
--- bzrlib/transport/fakevfat.py 2009-03-23 14:59:43 +0000
+++ bzrlib/transport/fakevfat.py 2010-02-11 09:31:16 +0000
@@ -41,7 +41,7 @@
41import re41import re
4242
43from bzrlib.errors import TransportNotPossible43from bzrlib.errors import TransportNotPossible
44from bzrlib.transport.decorator import TransportDecorator, DecoratorServer44from bzrlib.transport import decorator
4545
4646
47# TODO: It might be nice if these hooks were available in a more general way47# TODO: It might be nice if these hooks were available in a more general way
@@ -52,7 +52,7 @@
52# which are not implemented here fail by default?52# which are not implemented here fail by default?
5353
5454
55class FakeVFATTransportDecorator(TransportDecorator):55class FakeVFATTransportDecorator(decorator.TransportDecorator):
56 """A decorator that can convert any transport to be readonly.56 """A decorator that can convert any transport to be readonly.
5757
58 This is requested via the 'vfat+' prefix to get_transport().58 This is requested via the 'vfat+' prefix to get_transport().
@@ -99,17 +99,7 @@
99 return self._decorated.put_file(self._squash_name(relpath), f, mode)99 return self._decorated.put_file(self._squash_name(relpath), f, mode)
100100
101101
102class FakeVFATServer(DecoratorServer):
103 """A server that suggests connections through FakeVFATTransportDecorator
104
105 For use in testing.
106 """
107
108 def get_decorator_class(self):
109 return FakeVFATTransportDecorator
110
111
112def get_test_permutations():102def get_test_permutations():
113 """Return the permutations to be used in testing."""103 """Return the permutations to be used in testing."""
114 return [(FakeVFATTransportDecorator, FakeVFATServer),104 from bzrlib.tests import test_server
115 ]105 return [(FakeVFATTransportDecorator, test_server.FakeVFATServer),]
116106
=== modified file 'bzrlib/transport/local.py'
--- bzrlib/transport/local.py 2010-01-07 03:03:01 +0000
+++ bzrlib/transport/local.py 2010-02-11 09:31:16 +0000
@@ -39,14 +39,14 @@
39from bzrlib.transport import LateReadError39from bzrlib.transport import LateReadError
40""")40""")
4141
42from bzrlib.transport import Transport, Server42from bzrlib import transport
4343
4444
45_append_flags = os.O_CREAT | os.O_APPEND | os.O_WRONLY | osutils.O_BINARY45_append_flags = os.O_CREAT | os.O_APPEND | os.O_WRONLY | osutils.O_BINARY
46_put_non_atomic_flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | osutils.O_BINARY46_put_non_atomic_flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | osutils.O_BINARY
4747
4848
49class LocalTransport(Transport):49class LocalTransport(transport.Transport):
50 """This is the transport agent for local filesystem access."""50 """This is the transport agent for local filesystem access."""
5151
52 def __init__(self, base):52 def __init__(self, base):
@@ -554,23 +554,7 @@
554 return EmulatedWin32LocalTransport(abspath)554 return EmulatedWin32LocalTransport(abspath)
555555
556556
557class LocalURLServer(Server):
558 """A pretend server for local transports, using file:// urls.
559
560 Of course no actual server is required to access the local filesystem, so
561 this just exists to tell the test code how to get to it.
562 """
563
564 def start_server(self):
565 pass
566
567 def get_url(self):
568 """See Transport.Server.get_url."""
569 return urlutils.local_path_to_url('')
570
571
572def get_test_permutations():557def get_test_permutations():
573 """Return the permutations to be used in testing."""558 """Return the permutations to be used in testing."""
574 return [559 from bzrlib.tests import test_server
575 (LocalTransport, LocalURLServer),560 return [(LocalTransport, test_server.LocalURLServer),]
576 ]
577561
=== modified file 'bzrlib/transport/log.py'
--- bzrlib/transport/log.py 2010-02-04 16:06:36 +0000
+++ bzrlib/transport/log.py 2010-02-11 09:31:16 +0000
@@ -26,18 +26,10 @@
26import types26import types
2727
28from bzrlib.trace import mutter28from bzrlib.trace import mutter
29from bzrlib.transport.decorator import (29from bzrlib.transport import decorator
30 TransportDecorator,30
31 )31
32from bzrlib.transport.trace import (32class TransportLogDecorator(decorator.TransportDecorator):
33 DecoratorServer,
34 TransportTraceDecorator,
35 )
36
37
38
39
40class TransportLogDecorator(TransportDecorator):
41 """Decorator for Transports that logs interesting operations to .bzr.log.33 """Decorator for Transports that logs interesting operations to .bzr.log.
4234
43 In general we want to log things that usually take a network round trip35 In general we want to log things that usually take a network round trip
@@ -156,13 +148,7 @@
156 return t148 return t
157149
158150
159class LogDecoratorServer(DecoratorServer):
160 """Server for testing."""
161
162 def get_decorator_class(self):
163 return TransportLogDecorator
164
165
166def get_test_permutations():151def get_test_permutations():
167 """Return the permutations to be used in testing."""152 """Return the permutations to be used in testing."""
168 return [(TransportLogDecorator, LogDecoratorServer)]153 from bzrlib.tests import test_server
154 return [(TransportLogDecorator, test_server.LogDecoratorServer)]
169155
=== modified file 'bzrlib/transport/memory.py'
--- bzrlib/transport/memory.py 2010-01-08 17:28:25 +0000
+++ bzrlib/transport/memory.py 2010-02-11 09:31:16 +0000
@@ -28,6 +28,7 @@
28import warnings28import warnings
2929
30from bzrlib import (30from bzrlib import (
31 transport,
31 urlutils,32 urlutils,
32 )33 )
33from bzrlib.errors import (34from bzrlib.errors import (
@@ -42,10 +43,6 @@
42 AppendBasedFileStream,43 AppendBasedFileStream,
43 _file_streams,44 _file_streams,
44 LateReadError,45 LateReadError,
45 register_transport,
46 Server,
47 Transport,
48 unregister_transport,
49 )46 )
5047
5148
@@ -64,7 +61,7 @@
64 self.st_mode = S_IFDIR | perms61 self.st_mode = S_IFDIR | perms
6562
6663
67class MemoryTransport(Transport):64class MemoryTransport(transport.Transport):
68 """This is an in memory file system for transient data storage."""65 """This is an in memory file system for transient data storage."""
6966
70 def __init__(self, url=""):67 def __init__(self, url=""):
@@ -303,7 +300,7 @@
303 self.transport = None300 self.transport = None
304301
305302
306class MemoryServer(Server):303class MemoryServer(transport.Server):
307 """Server for the MemoryTransport for testing with."""304 """Server for the MemoryTransport for testing with."""
308305
309 def start_server(self):306 def start_server(self):
@@ -312,22 +309,26 @@
312 self._locks = {}309 self._locks = {}
313 self._scheme = "memory+%s:///" % id(self)310 self._scheme = "memory+%s:///" % id(self)
314 def memory_factory(url):311 def memory_factory(url):
315 result = MemoryTransport(url)312 from bzrlib.transport import memory
313 result = memory.MemoryTransport(url)
316 result._dirs = self._dirs314 result._dirs = self._dirs
317 result._files = self._files315 result._files = self._files
318 result._locks = self._locks316 result._locks = self._locks
319 return result317 return result
320 self._memory_factory = memory_factory318 self._memory_factory = memory_factory
321 register_transport(self._scheme, self._memory_factory)319 transport.register_transport(self._scheme, self._memory_factory)
322320
323 def stop_server(self):321 def stop_server(self):
324 # unregister this server322 # unregister this server
325 unregister_transport(self._scheme, self._memory_factory)323 transport.unregister_transport(self._scheme, self._memory_factory)
326324
327 def get_url(self):325 def get_url(self):
328 """See bzrlib.transport.Server.get_url."""326 """See bzrlib.transport.Server.get_url."""
329 return self._scheme327 return self._scheme
330328
329 def get_bogus_url(self):
330 raise NotImplementedError
331
331332
332def get_test_permutations():333def get_test_permutations():
333 """Return the permutations to be used in testing."""334 """Return the permutations to be used in testing."""
334335
=== modified file 'bzrlib/transport/nosmart.py'
--- bzrlib/transport/nosmart.py 2009-03-23 14:59:43 +0000
+++ bzrlib/transport/nosmart.py 2010-02-11 09:31:16 +0000
@@ -22,10 +22,10 @@
22"""22"""
2323
24from bzrlib import errors24from bzrlib import errors
25from bzrlib.transport.decorator import TransportDecorator, DecoratorServer25from bzrlib.transport import decorator
2626
2727
28class NoSmartTransportDecorator(TransportDecorator):28class NoSmartTransportDecorator(decorator.TransportDecorator):
29 """A decorator for transports that disables get_smart_medium."""29 """A decorator for transports that disables get_smart_medium."""
3030
31 @classmethod31 @classmethod
@@ -36,14 +36,8 @@
36 raise errors.NoSmartMedium(self)36 raise errors.NoSmartMedium(self)
3737
3838
39class NoSmartTransportServer(DecoratorServer):
40 """Server for the NoSmartTransportDecorator for testing with."""
41
42 def get_decorator_class(self):
43 return NoSmartTransportDecorator
44
45
46def get_test_permutations():39def get_test_permutations():
47 """Return the permutations to be used in testing."""40 """Return the permutations to be used in testing."""
48 return [(NoSmartTransportDecorator, NoSmartTransportServer)]41 from bzrlib.tests import test_server
42 return [(NoSmartTransportDecorator, test_server.NoSmartTransportServer)]
4943
5044
=== modified file 'bzrlib/transport/pathfilter.py'
--- bzrlib/transport/pathfilter.py 2010-01-07 03:03:01 +0000
+++ bzrlib/transport/pathfilter.py 2010-02-11 09:31:16 +0000
@@ -174,22 +174,7 @@
174 return self._call('stat', relpath)174 return self._call('stat', relpath)
175175
176176
177class TestingPathFilteringServer(PathFilteringServer):
178
179 def __init__(self):
180 """TestingChrootServer is not usable until start_server is called."""
181
182 def start_server(self, backing_server=None):
183 """Setup the Chroot on backing_server."""
184 if backing_server is not None:
185 self.backing_transport = get_transport(backing_server.get_url())
186 else:
187 self.backing_transport = get_transport('.')
188 self.backing_transport.clone('added-by-filter').ensure_base()
189 self.filter_func = lambda x: 'added-by-filter/' + x
190 PathFilteringServer.start_server(self)
191
192
193def get_test_permutations():177def get_test_permutations():
194 """Return the permutations to be used in testing."""178 """Return the permutations to be used in testing."""
195 return [(PathFilteringTransport, TestingPathFilteringServer)]179 from bzrlib.tests import test_server
180 return [(PathFilteringTransport, test_server.TestingPathFilteringServer)]
196181
=== modified file 'bzrlib/transport/readonly.py'
--- bzrlib/transport/readonly.py 2009-03-24 01:53:42 +0000
+++ bzrlib/transport/readonly.py 2010-02-11 09:31:16 +0000
@@ -17,10 +17,10 @@
17"""Implementation of Transport that adapts another transport to be readonly."""17"""Implementation of Transport that adapts another transport to be readonly."""
1818
19from bzrlib.errors import TransportNotPossible, NoSmartMedium19from bzrlib.errors import TransportNotPossible, NoSmartMedium
20from bzrlib.transport.decorator import TransportDecorator, DecoratorServer20from bzrlib.transport import decorator
2121
2222
23class ReadonlyTransportDecorator(TransportDecorator):23class ReadonlyTransportDecorator(decorator.TransportDecorator):
24 """A decorator that can convert any transport to be readonly.24 """A decorator that can convert any transport to be readonly.
2525
26 This is requested via the 'readonly+' prefix to get_transport().26 This is requested via the 'readonly+' prefix to get_transport().
@@ -78,15 +78,7 @@
78 raise NoSmartMedium(self)78 raise NoSmartMedium(self)
7979
8080
81
82class ReadonlyServer(DecoratorServer):
83 """Server for the ReadonlyTransportDecorator for testing with."""
84
85 def get_decorator_class(self):
86 return ReadonlyTransportDecorator
87
88
89def get_test_permutations():81def get_test_permutations():
90 """Return the permutations to be used in testing."""82 """Return the permutations to be used in testing."""
91 return [(ReadonlyTransportDecorator, ReadonlyServer),83 from bzrlib.tests import test_server
92 ]84 return [(ReadonlyTransportDecorator, test_server.ReadonlyServer),]
9385
=== modified file 'bzrlib/transport/remote.py'
--- bzrlib/transport/remote.py 2009-03-24 01:53:42 +0000
+++ bzrlib/transport/remote.py 2010-02-11 09:31:16 +0000
@@ -601,5 +601,5 @@
601 """Return (transport, server) permutations for testing."""601 """Return (transport, server) permutations for testing."""
602 ### We may need a little more test framework support to construct an602 ### We may need a little more test framework support to construct an
603 ### appropriate RemoteTransport in the future.603 ### appropriate RemoteTransport in the future.
604 from bzrlib.smart import server604 from bzrlib.tests import test_server
605 return [(RemoteTCPTransport, server.SmartTCPServer_for_testing)]605 return [(RemoteTCPTransport, test_server.SmartTCPServer_for_testing)]
606606
=== modified file 'bzrlib/transport/trace.py'
--- bzrlib/transport/trace.py 2009-07-02 03:48:56 +0000
+++ bzrlib/transport/trace.py 2010-02-11 09:31:16 +0000
@@ -20,10 +20,10 @@
20and then delegates it.20and then delegates it.
21"""21"""
2222
23from bzrlib.transport.decorator import TransportDecorator, DecoratorServer23from bzrlib.transport import decorator
2424
2525
26class TransportTraceDecorator(TransportDecorator):26class TransportTraceDecorator(decorator.TransportDecorator):
27 """A tracing decorator for Transports.27 """A tracing decorator for Transports.
2828
29 Calls that potentially perform IO are logged to self._activity. The29 Calls that potentially perform IO are logged to self._activity. The
@@ -43,7 +43,7 @@
4343
44 _decorated is a private parameter for cloning.44 _decorated is a private parameter for cloning.
45 """45 """
46 TransportDecorator.__init__(self, url, _decorated)46 super(TransportTraceDecorator, self).__init__(url, _decorated)
47 if _from_transport is None:47 if _from_transport is None:
48 # newly created48 # newly created
49 self._activity = []49 self._activity = []
@@ -169,13 +169,7 @@
169 self._activity.append(operation_tuple)169 self._activity.append(operation_tuple)
170170
171171
172class TraceServer(DecoratorServer):
173 """Server for the TransportTraceDecorator for testing with."""
174
175 def get_decorator_class(self):
176 return TransportTraceDecorator
177
178
179def get_test_permutations():172def get_test_permutations():
180 """Return the permutations to be used in testing."""173 """Return the permutations to be used in testing."""
181 return [(TransportTraceDecorator, TraceServer)]174 from bzrlib.tests import test_server
175 return [(TransportTraceDecorator, test_server.TraceServer)]
182176
=== modified file 'bzrlib/transport/unlistable.py'
--- bzrlib/transport/unlistable.py 2009-03-23 14:59:43 +0000
+++ bzrlib/transport/unlistable.py 2010-02-11 09:31:16 +0000
@@ -18,10 +18,10 @@
1818
19import bzrlib.errors as errors19import bzrlib.errors as errors
20from bzrlib.transport import Transport20from bzrlib.transport import Transport
21from bzrlib.transport.decorator import TransportDecorator, DecoratorServer21from bzrlib.transport import decorator
2222
2323
24class UnlistableTransportDecorator(TransportDecorator):24class UnlistableTransportDecorator(decorator.TransportDecorator):
25 """A transport that disables file listing for testing."""25 """A transport that disables file listing for testing."""
2626
27 @classmethod27 @classmethod
@@ -39,14 +39,7 @@
39 Transport.list_dir(self, relpath)39 Transport.list_dir(self, relpath)
4040
4141
42class UnlistableServer(DecoratorServer):
43 """Server for the UnlistableTransportDecorator for testing with."""
44
45 def get_decorator_class(self):
46 return UnlistableTransportDecorator
47
48
49def get_test_permutations():42def get_test_permutations():
50 """Return the permutations to be used in testing."""43 """Return the permutations to be used in testing."""
51 return [(UnlistableTransportDecorator, UnlistableServer),44 from bzrlib.tests import test_server
52 ]45 return [(UnlistableTransportDecorator, test_server.UnlistableServer),]