Merge lp:~vila/bzr/move-test-servers into lp:bzr
- move-test-servers
- Merge into bzr.dev
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Approve | ||
Review via email: mp+18960@code.launchpad.net |
Commit message
Description of the change
Vincent Ladeuil (vila) wrote : | # |
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).
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.
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.
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.
> 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
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.
>> 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://
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.
-Rob
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.
I'd slightly prefer .servers:
1- submodules seem to occasionally cause more annoying python import
behaviour (circularity etc) than sibling modules
2- bzrlib.
--
Martin <http://
Robert Collins (lifeless) wrote : | # |
On Thu, 2010-02-11 at 02:51 +0000, Martin Pool wrote:
>
> > Perhaps bzrlib.
>
> 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.
This should be pretty fast after it is tried once, because after that
the dentry cache is hot.
> 2- bzrlib.
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.
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
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.
>>
>> 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.
> 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.
>
> 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.
> 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://
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.
> >>
> >> 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.
> > 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.
case do we seem to have an a-priori need to expose things from within
the namespace.
> >> 2- bzrlib.
> >
> > 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.
> > 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
Vincent Ladeuil (vila) wrote : | # |
Cough, so to clear up a few points:
- bzrlib.
- 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|
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|
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.
- 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.
Vincent Ladeuil (vila) wrote : | # |
I forgot to mention that I've put all test servers into
bzrlib.
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*.
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
>>>> 2- bzrlib.
>>> 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.
>>> 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://
iEYEARECAAYFAkt
MfYAnifbuaB2Yxa
=asMl
-----END PGP SIGNATURE-----
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://
iEYEARECAAYFAkt
cVQAn1pgkeERuoC
=QGYJ
-----END PGP SIGNATURE-----
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.
you can't use a Memory Transport without it.
Vincent
Preview Diff
1 | === modified file 'NEWS' |
2 | --- NEWS 2010-02-11 06:15:33 +0000 |
3 | +++ NEWS 2010-02-11 09:31:16 +0000 |
4 | @@ -20,6 +20,13 @@ |
5 | |
6 | * ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij) |
7 | |
8 | +* All test servers have been moved out of the bzrlib.transport hierarchy to |
9 | + bzrlib.tests.test_server *except* for MemoryServer, ChrootServer and |
10 | + PathFilteringServer. ``bzrlib`` users may encounter test failures that can |
11 | + be fixed by updating the related imports from ``bzrlib.transport.xxx`` to |
12 | + ``bzrlib.tests.test_server``. |
13 | + (Vincent Ladeuil) |
14 | + |
15 | New Features |
16 | ************ |
17 | |
18 | |
19 | === modified file 'bzrlib/builtins.py' |
20 | --- bzrlib/builtins.py 2010-02-11 05:43:31 +0000 |
21 | +++ bzrlib/builtins.py 2010-02-11 09:31:16 +0000 |
22 | @@ -54,6 +54,7 @@ |
23 | ) |
24 | from bzrlib.branch import Branch |
25 | from bzrlib.conflicts import ConflictList |
26 | +from bzrlib.transport import memory |
27 | from bzrlib.revisionspec import RevisionSpec, RevisionInfo |
28 | from bzrlib.smtp_connection import SMTPConnection |
29 | from bzrlib.workingtree import WorkingTree |
30 | @@ -3444,11 +3445,11 @@ |
31 | from bzrlib.tests import stub_sftp |
32 | return stub_sftp.SFTPAbsoluteServer |
33 | if typestring == "memory": |
34 | - from bzrlib.transport.memory import MemoryServer |
35 | - return MemoryServer |
36 | + from bzrlib.tests import test_server |
37 | + return memory.MemoryServer |
38 | if typestring == "fakenfs": |
39 | - from bzrlib.transport.fakenfs import FakeNFSServer |
40 | - return FakeNFSServer |
41 | + from bzrlib.tests import test_server |
42 | + return test_server.FakeNFSServer |
43 | msg = "No known transport type %s. Supported types are: sftp\n" %\ |
44 | (typestring) |
45 | raise errors.BzrCommandError(msg) |
46 | |
47 | === modified file 'bzrlib/smart/server.py' |
48 | --- bzrlib/smart/server.py 2010-01-07 03:03:01 +0000 |
49 | +++ bzrlib/smart/server.py 2010-02-11 09:31:16 +0000 |
50 | @@ -236,91 +236,6 @@ |
51 | SmartTCPServer.hooks = SmartServerHooks() |
52 | |
53 | |
54 | -class SmartTCPServer_for_testing(SmartTCPServer): |
55 | - """Server suitable for use by transport tests. |
56 | - |
57 | - This server is backed by the process's cwd. |
58 | - """ |
59 | - |
60 | - def __init__(self, thread_name_suffix=''): |
61 | - SmartTCPServer.__init__(self, None) |
62 | - self.client_path_extra = None |
63 | - self.thread_name_suffix = thread_name_suffix |
64 | - |
65 | - def get_backing_transport(self, backing_transport_server): |
66 | - """Get a backing transport from a server we are decorating.""" |
67 | - return transport.get_transport(backing_transport_server.get_url()) |
68 | - |
69 | - def start_server(self, backing_transport_server=None, |
70 | - client_path_extra='/extra/'): |
71 | - """Set up server for testing. |
72 | - |
73 | - :param backing_transport_server: backing server to use. If not |
74 | - specified, a LocalURLServer at the current working directory will |
75 | - be used. |
76 | - :param client_path_extra: a path segment starting with '/' to append to |
77 | - the root URL for this server. For instance, a value of '/foo/bar/' |
78 | - will mean the root of the backing transport will be published at a |
79 | - URL like `bzr://127.0.0.1:nnnn/foo/bar/`, rather than |
80 | - `bzr://127.0.0.1:nnnn/`. Default value is `extra`, so that tests |
81 | - by default will fail unless they do the necessary path translation. |
82 | - """ |
83 | - if not client_path_extra.startswith('/'): |
84 | - raise ValueError(client_path_extra) |
85 | - from bzrlib.transport.chroot import ChrootServer |
86 | - if backing_transport_server is None: |
87 | - from bzrlib.transport.local import LocalURLServer |
88 | - backing_transport_server = LocalURLServer() |
89 | - self.chroot_server = ChrootServer( |
90 | - self.get_backing_transport(backing_transport_server)) |
91 | - self.chroot_server.start_server() |
92 | - self.backing_transport = transport.get_transport( |
93 | - self.chroot_server.get_url()) |
94 | - self.root_client_path = self.client_path_extra = client_path_extra |
95 | - self.start_background_thread(self.thread_name_suffix) |
96 | - |
97 | - def stop_server(self): |
98 | - self.stop_background_thread() |
99 | - self.chroot_server.stop_server() |
100 | - |
101 | - def get_url(self): |
102 | - url = super(SmartTCPServer_for_testing, self).get_url() |
103 | - return url[:-1] + self.client_path_extra |
104 | - |
105 | - def get_bogus_url(self): |
106 | - """Return a URL which will fail to connect""" |
107 | - return 'bzr://127.0.0.1:1/' |
108 | - |
109 | - |
110 | -class ReadonlySmartTCPServer_for_testing(SmartTCPServer_for_testing): |
111 | - """Get a readonly server for testing.""" |
112 | - |
113 | - def get_backing_transport(self, backing_transport_server): |
114 | - """Get a backing transport from a server we are decorating.""" |
115 | - url = 'readonly+' + backing_transport_server.get_url() |
116 | - return transport.get_transport(url) |
117 | - |
118 | - |
119 | -class SmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing): |
120 | - """A variation of SmartTCPServer_for_testing that limits the client to |
121 | - using RPCs in protocol v2 (i.e. bzr <= 1.5). |
122 | - """ |
123 | - |
124 | - def get_url(self): |
125 | - url = super(SmartTCPServer_for_testing_v2_only, self).get_url() |
126 | - url = 'bzr-v2://' + url[len('bzr://'):] |
127 | - return url |
128 | - |
129 | - |
130 | -class ReadonlySmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing_v2_only): |
131 | - """Get a readonly server for testing.""" |
132 | - |
133 | - def get_backing_transport(self, backing_transport_server): |
134 | - """Get a backing transport from a server we are decorating.""" |
135 | - url = 'readonly+' + backing_transport_server.get_url() |
136 | - return transport.get_transport(url) |
137 | - |
138 | - |
139 | def _local_path_for_transport(transport): |
140 | """Return a local path for transport, if reasonably possible. |
141 | |
142 | |
143 | === modified file 'bzrlib/tests/__init__.py' |
144 | --- bzrlib/tests/__init__.py 2010-02-11 04:02:41 +0000 |
145 | +++ bzrlib/tests/__init__.py 2010-02-11 09:31:16 +0000 |
146 | @@ -101,13 +101,17 @@ |
147 | deprecated_passed, |
148 | ) |
149 | import bzrlib.trace |
150 | -from bzrlib.transport import get_transport, pathfilter |
151 | +from bzrlib.transport import ( |
152 | + get_transport, |
153 | + memory, |
154 | + pathfilter, |
155 | + ) |
156 | import bzrlib.transport |
157 | -from bzrlib.transport.local import LocalURLServer |
158 | -from bzrlib.transport.memory import MemoryServer |
159 | -from bzrlib.transport.readonly import ReadonlyServer |
160 | from bzrlib.trace import mutter, note |
161 | -from bzrlib.tests import TestUtil |
162 | +from bzrlib.tests import ( |
163 | + test_server, |
164 | + TestUtil, |
165 | + ) |
166 | from bzrlib.tests.http_server import HttpServer |
167 | from bzrlib.tests.TestUtil import ( |
168 | TestSuite, |
169 | @@ -124,7 +128,7 @@ |
170 | # shown frame is the test code, not our assertXYZ. |
171 | __unittest = 1 |
172 | |
173 | -default_transport = LocalURLServer |
174 | +default_transport = test_server.LocalURLServer |
175 | |
176 | |
177 | _unitialized_attr = object() |
178 | @@ -1040,7 +1044,8 @@ |
179 | if t.base.endswith('/work/'): |
180 | # we have safety net/test root/work |
181 | t = t.clone('../..') |
182 | - elif isinstance(transport_server, server.SmartTCPServer_for_testing): |
183 | + elif isinstance(transport_server, |
184 | + test_server.SmartTCPServer_for_testing): |
185 | # The smart server adds a path similar to work, which is traversed |
186 | # up from by the client. But the server is chrooted - the actual |
187 | # backing transport is not escaped from, and VFS requests to the |
188 | @@ -2175,7 +2180,7 @@ |
189 | if self.__readonly_server is None: |
190 | if self.transport_readonly_server is None: |
191 | # readonly decorator requested |
192 | - self.__readonly_server = ReadonlyServer() |
193 | + self.__readonly_server = test_server.ReadonlyServer() |
194 | else: |
195 | # explicit readonly transport. |
196 | self.__readonly_server = self.create_transport_readonly_server() |
197 | @@ -2204,7 +2209,7 @@ |
198 | is no means to override it. |
199 | """ |
200 | if self.__vfs_server is None: |
201 | - self.__vfs_server = MemoryServer() |
202 | + self.__vfs_server = memory.MemoryServer() |
203 | self.start_server(self.__vfs_server) |
204 | return self.__vfs_server |
205 | |
206 | @@ -2367,7 +2372,7 @@ |
207 | return made_control.create_repository(shared=shared) |
208 | |
209 | def make_smart_server(self, path): |
210 | - smart_server = server.SmartTCPServer_for_testing() |
211 | + smart_server = test_server.SmartTCPServer_for_testing() |
212 | self.start_server(smart_server, self.get_server()) |
213 | remote_transport = get_transport(smart_server.get_url()).clone(path) |
214 | return remote_transport |
215 | @@ -2400,7 +2405,7 @@ |
216 | |
217 | def setup_smart_server_with_call_log(self): |
218 | """Sets up a smart server as the transport server with a call log.""" |
219 | - self.transport_server = server.SmartTCPServer_for_testing |
220 | + self.transport_server = test_server.SmartTCPServer_for_testing |
221 | self.hpss_calls = [] |
222 | import traceback |
223 | # Skip the current stack down to the caller of |
224 | @@ -2619,7 +2624,7 @@ |
225 | # We can only make working trees locally at the moment. If the |
226 | # transport can't support them, then we keep the non-disk-backed |
227 | # branch and create a local checkout. |
228 | - if self.vfs_transport_factory is LocalURLServer: |
229 | + if self.vfs_transport_factory is test_server.LocalURLServer: |
230 | # the branch is colocated on disk, we cannot create a checkout. |
231 | # hopefully callers will expect this. |
232 | local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath)) |
233 | @@ -2685,7 +2690,7 @@ |
234 | |
235 | def setUp(self): |
236 | super(ChrootedTestCase, self).setUp() |
237 | - if not self.vfs_transport_factory == MemoryServer: |
238 | + if not self.vfs_transport_factory == memory.MemoryServer: |
239 | self.transport_readonly_server = HttpServer |
240 | |
241 | |
242 | |
243 | === modified file 'bzrlib/tests/blackbox/test_branch.py' |
244 | --- bzrlib/tests/blackbox/test_branch.py 2010-01-12 06:39:06 +0000 |
245 | +++ bzrlib/tests/blackbox/test_branch.py 2010-02-11 09:31:16 +0000 |
246 | @@ -31,6 +31,7 @@ |
247 | from bzrlib.tests import ( |
248 | KnownFailure, |
249 | HardlinkFeature, |
250 | + test_server, |
251 | ) |
252 | from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer |
253 | from bzrlib.urlutils import local_path_to_url, strip_trailing_slash |
254 | @@ -308,8 +309,7 @@ |
255 | |
256 | def test_branch_stacked_from_smart_server(self): |
257 | # We can branch stacking on a smart server |
258 | - from bzrlib.smart.server import SmartTCPServer_for_testing |
259 | - self.transport_server = SmartTCPServer_for_testing |
260 | + self.transport_server = test_server.SmartTCPServer_for_testing |
261 | trunk = self.make_branch('mainline', format='1.9') |
262 | out, err = self.run_bzr( |
263 | ['branch', '--stacked', self.get_url('mainline'), 'shallow']) |
264 | |
265 | === modified file 'bzrlib/tests/blackbox/test_cat.py' |
266 | --- bzrlib/tests/blackbox/test_cat.py 2010-01-12 07:02:54 +0000 |
267 | +++ bzrlib/tests/blackbox/test_cat.py 2010-02-11 09:31:16 +0000 |
268 | @@ -22,6 +22,7 @@ |
269 | import os |
270 | |
271 | from bzrlib import tests |
272 | +from bzrlib.transport import memory |
273 | |
274 | |
275 | class TestCat(tests.TestCaseWithTransport): |
276 | @@ -195,6 +196,6 @@ |
277 | self.assertEqual('contents of README\n', out) |
278 | |
279 | def test_cat_nonexistent_branch(self): |
280 | - self.vfs_transport_factory = tests.MemoryServer |
281 | + self.vfs_transport_factory = memory.MemoryServer |
282 | self.run_bzr_error(['^bzr: ERROR: Not a branch'], |
283 | ['cat', self.get_url()]) |
284 | |
285 | === modified file 'bzrlib/tests/blackbox/test_info.py' |
286 | --- bzrlib/tests/blackbox/test_info.py 2010-02-10 17:52:08 +0000 |
287 | +++ bzrlib/tests/blackbox/test_info.py 2010-02-11 09:31:16 +0000 |
288 | @@ -31,6 +31,7 @@ |
289 | ) |
290 | from bzrlib.transport import memory |
291 | |
292 | + |
293 | class TestInfo(tests.TestCaseWithTransport): |
294 | |
295 | def setUp(self): |
296 | |
297 | === modified file 'bzrlib/tests/blackbox/test_push.py' |
298 | --- bzrlib/tests/blackbox/test_push.py 2010-01-07 03:03:01 +0000 |
299 | +++ bzrlib/tests/blackbox/test_push.py 2010-02-11 09:31:16 +0000 |
300 | @@ -35,6 +35,7 @@ |
301 | blackbox, |
302 | http_server, |
303 | test_foreign, |
304 | + test_server, |
305 | ) |
306 | from bzrlib.transport import memory |
307 | |
308 | |
309 | === modified file 'bzrlib/tests/blackbox/test_selftest.py' |
310 | --- bzrlib/tests/blackbox/test_selftest.py 2010-02-10 17:52:08 +0000 |
311 | +++ bzrlib/tests/blackbox/test_selftest.py 2010-02-11 09:31:16 +0000 |
312 | @@ -24,7 +24,7 @@ |
313 | features, |
314 | stub_sftp, |
315 | ) |
316 | - |
317 | +from bzrlib.transport import memory |
318 | |
319 | class SelfTestPatch: |
320 | |
321 | @@ -82,10 +82,8 @@ |
322 | def test_transport_set_to_memory(self): |
323 | # Test that we can pass a transport to the selftest core - memory |
324 | # version. |
325 | - import bzrlib.transport.memory |
326 | params = self.get_params_passed_to_core('selftest --transport=memory') |
327 | - self.assertEqual(bzrlib.transport.memory.MemoryServer, |
328 | - params[1]["transport"]) |
329 | + self.assertEqual(memory.MemoryServer, params[1]["transport"]) |
330 | |
331 | def test_parameters_passed_to_core(self): |
332 | params = self.get_params_passed_to_core('selftest --list-only') |
333 | |
334 | === modified file 'bzrlib/tests/blackbox/test_send.py' |
335 | --- bzrlib/tests/blackbox/test_send.py 2009-11-28 00:48:03 +0000 |
336 | +++ bzrlib/tests/blackbox/test_send.py 2010-02-11 09:31:16 +0000 |
337 | @@ -26,6 +26,7 @@ |
338 | tests, |
339 | ) |
340 | from bzrlib.bundle import serializer |
341 | +from bzrlib.transport import memory |
342 | |
343 | |
344 | def load_tests(standard_tests, module, loader): |
345 | @@ -280,7 +281,7 @@ |
346 | self.assertEqual('rev3', md.revision_id) |
347 | |
348 | def test_nonexistant_branch(self): |
349 | - self.vfs_transport_factory = tests.MemoryServer |
350 | + self.vfs_transport_factory = memory.MemoryServer |
351 | location = self.get_url('absentdir/') |
352 | out, err = self.run_bzr(["send", "--from", location], retcode=3) |
353 | self.assertEqual(out, '') |
354 | |
355 | === modified file 'bzrlib/tests/ftp_server/medusa_based.py' |
356 | --- bzrlib/tests/ftp_server/medusa_based.py 2010-01-08 03:35:09 +0000 |
357 | +++ bzrlib/tests/ftp_server/medusa_based.py 2010-02-11 09:31:16 +0000 |
358 | @@ -33,8 +33,8 @@ |
359 | from bzrlib import ( |
360 | tests, |
361 | trace, |
362 | - transport, |
363 | ) |
364 | +from bzrlib.tests import test_server |
365 | |
366 | |
367 | class test_filesystem(medusa.filesys.os_filesystem): |
368 | @@ -210,7 +210,7 @@ |
369 | trace.mutter('ftp_server %s: %s', type, message) |
370 | |
371 | |
372 | -class FTPTestServer(transport.Server): |
373 | +class FTPTestServer(test_server.TestServer): |
374 | """Common code for FTP server facilities.""" |
375 | |
376 | no_unicode_support = True |
377 | @@ -236,8 +236,8 @@ |
378 | self.logs.append(message) |
379 | |
380 | def start_server(self, vfs_server=None): |
381 | - from bzrlib.transport.local import LocalURLServer |
382 | - if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)): |
383 | + if not (vfs_server is None or isinstance(vfs_server, |
384 | + test_server.LocalURLServer)): |
385 | raise AssertionError( |
386 | "FTPServer currently assumes local transport, got %s" % vfs_server) |
387 | self._root = os.getcwdu() |
388 | |
389 | === modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py' |
390 | --- bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-01-13 15:30:22 +0000 |
391 | +++ bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-02-11 09:31:16 +0000 |
392 | @@ -29,8 +29,8 @@ |
393 | from bzrlib import ( |
394 | osutils, |
395 | trace, |
396 | - transport, |
397 | ) |
398 | +from bzrlib.tests import test_server |
399 | |
400 | |
401 | class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer): |
402 | @@ -133,7 +133,7 @@ |
403 | self.addr = self.socket.getsockname() |
404 | |
405 | |
406 | -class FTPTestServer(transport.Server): |
407 | +class FTPTestServer(test_server.TestServer): |
408 | """Common code for FTP server facilities.""" |
409 | |
410 | def __init__(self): |
411 | @@ -158,8 +158,8 @@ |
412 | self.logs.append(message) |
413 | |
414 | def start_server(self, vfs_server=None): |
415 | - from bzrlib.transport.local import LocalURLServer |
416 | - if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)): |
417 | + if not (vfs_server is None or isinstance(vfs_server, |
418 | + test_server.LocalURLServer)): |
419 | raise AssertionError( |
420 | "FTPServer currently assumes local transport, got %s" |
421 | % vfs_server) |
422 | |
423 | === modified file 'bzrlib/tests/http_server.py' |
424 | --- bzrlib/tests/http_server.py 2010-01-07 03:03:01 +0000 |
425 | +++ bzrlib/tests/http_server.py 2010-02-11 09:31:16 +0000 |
426 | @@ -31,6 +31,7 @@ |
427 | import urlparse |
428 | |
429 | from bzrlib import transport |
430 | +from bzrlib.tests import test_server |
431 | from bzrlib.transport import local |
432 | |
433 | |
434 | @@ -530,8 +531,9 @@ |
435 | """ |
436 | # XXX: TODO: make the server back onto vfs_server rather than local |
437 | # disk. |
438 | - if not (backing_transport_server is None or \ |
439 | - isinstance(backing_transport_server, local.LocalURLServer)): |
440 | + if not (backing_transport_server is None |
441 | + or isinstance(backing_transport_server, |
442 | + test_server.LocalURLServer)): |
443 | raise AssertionError( |
444 | "HTTPServer currently assumes local transport, got %s" % \ |
445 | backing_transport_server) |
446 | |
447 | === modified file 'bzrlib/tests/per_branch/__init__.py' |
448 | --- bzrlib/tests/per_branch/__init__.py 2009-08-17 06:17:21 +0000 |
449 | +++ bzrlib/tests/per_branch/__init__.py 2010-02-11 09:31:16 +0000 |
450 | @@ -32,14 +32,9 @@ |
451 | _legacy_formats, |
452 | ) |
453 | from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat |
454 | -from bzrlib.smart.server import ( |
455 | - ReadonlySmartTCPServer_for_testing, |
456 | - ReadonlySmartTCPServer_for_testing_v2_only, |
457 | - SmartTCPServer_for_testing, |
458 | - SmartTCPServer_for_testing_v2_only, |
459 | - ) |
460 | +from bzrlib.tests import test_server |
461 | from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir |
462 | -from bzrlib.transport.memory import MemoryServer |
463 | +from bzrlib.transport import memory |
464 | |
465 | |
466 | def make_scenarios(transport_server, transport_readonly_server, |
467 | @@ -148,18 +143,18 @@ |
468 | # Add RemoteBranch tests, which need a special server. |
469 | remote_branch_format = RemoteBranchFormat() |
470 | scenarios.extend(make_scenarios( |
471 | - SmartTCPServer_for_testing, |
472 | - ReadonlySmartTCPServer_for_testing, |
473 | + test_server.SmartTCPServer_for_testing, |
474 | + test_server.ReadonlySmartTCPServer_for_testing, |
475 | [(remote_branch_format, remote_branch_format._matchingbzrdir)], |
476 | - MemoryServer, |
477 | + memory.MemoryServer, |
478 | name_suffix='-default')) |
479 | # Also add tests for RemoteBranch with HPSS protocol v2 (i.e. bzr <1.6) |
480 | # server. |
481 | scenarios.extend(make_scenarios( |
482 | - SmartTCPServer_for_testing_v2_only, |
483 | - ReadonlySmartTCPServer_for_testing_v2_only, |
484 | + test_server.SmartTCPServer_for_testing_v2_only, |
485 | + test_server.ReadonlySmartTCPServer_for_testing_v2_only, |
486 | [(remote_branch_format, remote_branch_format._matchingbzrdir)], |
487 | - MemoryServer, |
488 | + memory.MemoryServer, |
489 | name_suffix='-v2')) |
490 | return scenarios |
491 | |
492 | |
493 | === modified file 'bzrlib/tests/per_branch/test_bound_sftp.py' |
494 | --- bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-10 17:52:08 +0000 |
495 | +++ bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-11 09:31:16 +0000 |
496 | @@ -25,16 +25,16 @@ |
497 | errors, |
498 | tests, |
499 | ) |
500 | -from bzrlib.transport.local import LocalURLServer |
501 | -from bzrlib.transport.memory import MemoryServer |
502 | +from bzrlib.tests import test_server |
503 | +from bzrlib.transport import memory |
504 | |
505 | |
506 | class BoundSFTPBranch(tests.TestCaseWithTransport): |
507 | |
508 | def setUp(self): |
509 | tests.TestCaseWithTransport.setUp(self) |
510 | - self.vfs_transport_factory = MemoryServer |
511 | - if self.transport_server is LocalURLServer: |
512 | + self.vfs_transport_factory = memory.MemoryServer |
513 | + if self.transport_server is test_server.LocalURLServer: |
514 | self.transport_server = None |
515 | |
516 | def create_branches(self): |
517 | |
518 | === modified file 'bzrlib/tests/per_branch/test_branch.py' |
519 | --- bzrlib/tests/per_branch/test_branch.py 2010-02-10 17:52:08 +0000 |
520 | +++ bzrlib/tests/per_branch/test_branch.py 2010-02-11 09:31:16 +0000 |
521 | @@ -37,7 +37,7 @@ |
522 | per_branch, |
523 | ) |
524 | from bzrlib.tests.http_server import HttpServer |
525 | -from bzrlib.transport.memory import MemoryServer |
526 | +from bzrlib.transport import memory |
527 | |
528 | |
529 | class TestTestCaseWithBranch(per_branch.TestCaseWithBranch): |
530 | @@ -512,7 +512,7 @@ |
531 | |
532 | def setUp(self): |
533 | super(ChrootedTests, self).setUp() |
534 | - if not self.vfs_transport_factory == MemoryServer: |
535 | + if not self.vfs_transport_factory == memory.MemoryServer: |
536 | self.transport_readonly_server = HttpServer |
537 | |
538 | def test_open_containing(self): |
539 | |
540 | === modified file 'bzrlib/tests/per_branch/test_hooks.py' |
541 | --- bzrlib/tests/per_branch/test_hooks.py 2010-02-10 17:52:08 +0000 |
542 | +++ bzrlib/tests/per_branch/test_hooks.py 2010-02-11 09:31:16 +0000 |
543 | @@ -23,8 +23,7 @@ |
544 | revision, |
545 | tests, |
546 | ) |
547 | -from bzrlib.smart import server |
548 | - |
549 | +from bzrlib.tests import test_server |
550 | |
551 | class ChangeBranchTipTestCase(tests.TestCaseWithMemoryTransport): |
552 | """Base TestCase for testing pre/post_change_branch_tip hooks.""" |
553 | @@ -151,8 +150,8 @@ |
554 | b = self.make_branch('.') |
555 | if isinstance(b, remote.RemoteBranch): |
556 | # RemoteBranch creation: |
557 | - if (self.transport_readonly_server == |
558 | - server.ReadonlySmartTCPServer_for_testing_v2_only): |
559 | + if (self.transport_readonly_server |
560 | + == test_server.ReadonlySmartTCPServer_for_testing_v2_only): |
561 | # Older servers: |
562 | self.assertEqual(3, len(self.hook_calls)) |
563 | # creates the branch via the VFS (for older servers) |
564 | |
565 | === modified file 'bzrlib/tests/per_branch/test_http.py' |
566 | --- bzrlib/tests/per_branch/test_http.py 2010-02-10 17:52:08 +0000 |
567 | +++ bzrlib/tests/per_branch/test_http.py 2010-02-11 09:31:16 +0000 |
568 | @@ -20,10 +20,9 @@ |
569 | branch, |
570 | errors, |
571 | ) |
572 | -from bzrlib.tests import per_branch |
573 | -from bzrlib.transport import ( |
574 | - chroot, |
575 | - local, |
576 | +from bzrlib.tests import ( |
577 | + per_branch, |
578 | + test_server, |
579 | ) |
580 | |
581 | |
582 | @@ -38,8 +37,8 @@ |
583 | |
584 | def setUp(self): |
585 | super(InaccessibleParentTests, self).setUp() |
586 | - if self.transport_server in (local.LocalURLServer, None): |
587 | - self.transport_readonly_server = chroot.TestingChrootServer |
588 | + if self.transport_server in (test_server.LocalURLServer, None): |
589 | + self.transport_readonly_server = test_server.TestingChrootServer |
590 | |
591 | def get_branch_with_invalid_parent(self): |
592 | """Get a branch whose get_parent will raise InaccessibleParent.""" |
593 | |
594 | === modified file 'bzrlib/tests/per_branch/test_push.py' |
595 | --- bzrlib/tests/per_branch/test_push.py 2010-02-10 17:52:08 +0000 |
596 | +++ bzrlib/tests/per_branch/test_push.py 2010-02-11 09:31:16 +0000 |
597 | @@ -38,8 +38,10 @@ |
598 | server, |
599 | repository as _mod_smart_repo, |
600 | ) |
601 | -from bzrlib.tests import per_branch |
602 | -from bzrlib.transport import local |
603 | +from bzrlib.tests import ( |
604 | + per_branch, |
605 | + test_server, |
606 | + ) |
607 | |
608 | |
609 | class TestPush(per_branch.TestCaseWithBranch): |
610 | @@ -149,7 +151,7 @@ |
611 | try: |
612 | tree = a_branch.bzrdir.create_workingtree() |
613 | except errors.NotLocalUrl: |
614 | - if self.vfs_transport_factory is local.LocalURLServer: |
615 | + if self.vfs_transport_factory is test_server.LocalURLServer: |
616 | # the branch is colocated on disk, we cannot create a checkout. |
617 | # hopefully callers will expect this. |
618 | local_controldir= bzrdir.BzrDir.open( |
619 | @@ -391,7 +393,7 @@ |
620 | super(EmptyPushSmartEffortTests, self).setUp() |
621 | # Create a smart server that publishes whatever the backing VFS server |
622 | # does. |
623 | - self.smart_server = server.SmartTCPServer_for_testing() |
624 | + self.smart_server = test_server.SmartTCPServer_for_testing() |
625 | self.start_server(self.smart_server, self.get_server()) |
626 | # Make two empty branches, 'empty' and 'target'. |
627 | self.empty_branch = self.make_branch('empty') |
628 | |
629 | === modified file 'bzrlib/tests/per_bzrdir/__init__.py' |
630 | --- bzrlib/tests/per_bzrdir/__init__.py 2009-07-10 06:45:04 +0000 |
631 | +++ bzrlib/tests/per_bzrdir/__init__.py 2010-02-11 09:31:16 +0000 |
632 | @@ -26,11 +26,12 @@ |
633 | |
634 | from bzrlib.bzrdir import BzrDirFormat |
635 | from bzrlib.tests import ( |
636 | - default_transport, |
637 | - multiply_tests, |
638 | - TestCaseWithTransport, |
639 | - ) |
640 | -from bzrlib.transport.memory import MemoryServer |
641 | + default_transport, |
642 | + multiply_tests, |
643 | + test_server, |
644 | + TestCaseWithTransport, |
645 | + ) |
646 | +from bzrlib.transport import memory |
647 | |
648 | |
649 | def make_scenarios(vfs_factory, transport_server, transport_readonly_server, |
650 | @@ -88,26 +89,20 @@ |
651 | None, |
652 | formats) |
653 | # This will always add scenarios using the smart server. |
654 | - from bzrlib.smart.server import ( |
655 | - ReadonlySmartTCPServer_for_testing, |
656 | - ReadonlySmartTCPServer_for_testing_v2_only, |
657 | - SmartTCPServer_for_testing, |
658 | - SmartTCPServer_for_testing_v2_only, |
659 | - ) |
660 | from bzrlib.remote import RemoteBzrDirFormat |
661 | # test the remote server behaviour when backed with a MemoryTransport |
662 | # Once for the current version |
663 | scenarios.extend(make_scenarios( |
664 | - MemoryServer, |
665 | - SmartTCPServer_for_testing, |
666 | - ReadonlySmartTCPServer_for_testing, |
667 | + memory.MemoryServer, |
668 | + test_server.SmartTCPServer_for_testing, |
669 | + test_server.ReadonlySmartTCPServer_for_testing, |
670 | [(RemoteBzrDirFormat())], |
671 | name_suffix='-default')) |
672 | # And once with < 1.6 - the 'v2' protocol. |
673 | scenarios.extend(make_scenarios( |
674 | - MemoryServer, |
675 | - SmartTCPServer_for_testing_v2_only, |
676 | - ReadonlySmartTCPServer_for_testing_v2_only, |
677 | + memory.MemoryServer, |
678 | + test_server.SmartTCPServer_for_testing_v2_only, |
679 | + test_server.ReadonlySmartTCPServer_for_testing_v2_only, |
680 | [(RemoteBzrDirFormat())], |
681 | name_suffix='-v2')) |
682 | # add the tests for the sub modules |
683 | |
684 | === modified file 'bzrlib/tests/per_interbranch/test_push.py' |
685 | --- bzrlib/tests/per_interbranch/test_push.py 2010-01-25 17:48:22 +0000 |
686 | +++ bzrlib/tests/per_interbranch/test_push.py 2010-02-11 09:31:16 +0000 |
687 | @@ -40,7 +40,7 @@ |
688 | TestCaseWithInterBranch, |
689 | ) |
690 | from bzrlib.transport import get_transport |
691 | -from bzrlib.transport.local import LocalURLServer |
692 | +from bzrlib.tests import test_server |
693 | |
694 | |
695 | # These tests are based on similar tests in |
696 | @@ -155,7 +155,7 @@ |
697 | try: |
698 | tree = a_branch.bzrdir.create_workingtree() |
699 | except errors.NotLocalUrl: |
700 | - if self.vfs_transport_factory is LocalURLServer: |
701 | + if self.vfs_transport_factory is test_server.LocalURLServer: |
702 | # the branch is colocated on disk, we cannot create a checkout. |
703 | # hopefully callers will expect this. |
704 | local_controldir = bzrdir.BzrDir.open(self.get_vfs_only_url('repo/tree')) |
705 | |
706 | === modified file 'bzrlib/tests/per_pack_repository.py' |
707 | --- bzrlib/tests/per_pack_repository.py 2010-01-25 17:48:22 +0000 |
708 | +++ bzrlib/tests/per_pack_repository.py 2010-02-11 09:31:16 +0000 |
709 | @@ -45,7 +45,6 @@ |
710 | from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a |
711 | from bzrlib.smart import ( |
712 | client, |
713 | - server, |
714 | ) |
715 | from bzrlib.tests import ( |
716 | TestCase, |
717 | @@ -54,10 +53,10 @@ |
718 | TestSkipped, |
719 | ) |
720 | from bzrlib.transport import ( |
721 | - fakenfs, |
722 | + get_transport, |
723 | memory, |
724 | - get_transport, |
725 | ) |
726 | +from bzrlib.tests import test_server |
727 | from bzrlib.tests.per_repository import TestCaseWithRepository |
728 | |
729 | |
730 | @@ -240,7 +239,7 @@ |
731 | |
732 | def test_commit_write_group_returns_new_pack_names(self): |
733 | # This test doesn't need real disk. |
734 | - self.vfs_transport_factory = tests.MemoryServer |
735 | + self.vfs_transport_factory = memory.MemoryServer |
736 | format = self.get_format() |
737 | repo = self.make_repository('foo', format=format) |
738 | repo.lock_write() |
739 | @@ -277,7 +276,7 @@ |
740 | def test_fail_obsolete_deletion(self): |
741 | # failing to delete obsolete packs is not fatal |
742 | format = self.get_format() |
743 | - server = fakenfs.FakeNFSServer() |
744 | + server = test_server.FakeNFSServer() |
745 | self.start_server(server) |
746 | transport = get_transport(server.get_url()) |
747 | bzrdir = self.get_format().initialize_on_transport(transport) |
748 | @@ -1068,7 +1067,7 @@ |
749 | super(TestSmartServerAutopack, self).setUp() |
750 | # Create a smart server that publishes whatever the backing VFS server |
751 | # does. |
752 | - self.smart_server = server.SmartTCPServer_for_testing() |
753 | + self.smart_server = test_server.SmartTCPServer_for_testing() |
754 | self.start_server(self.smart_server, self.get_server()) |
755 | # Log all HPSS calls into self.hpss_calls. |
756 | client._SmartClient.hooks.install_named_hook( |
757 | |
758 | === modified file 'bzrlib/tests/per_repository/__init__.py' |
759 | --- bzrlib/tests/per_repository/__init__.py 2009-07-22 17:22:06 +0000 |
760 | +++ bzrlib/tests/per_repository/__init__.py 2010-02-11 09:31:16 +0000 |
761 | @@ -32,19 +32,14 @@ |
762 | weaverepo, |
763 | ) |
764 | from bzrlib.remote import RemoteBzrDirFormat, RemoteRepositoryFormat |
765 | -from bzrlib.smart.server import ( |
766 | - ReadonlySmartTCPServer_for_testing, |
767 | - ReadonlySmartTCPServer_for_testing_v2_only, |
768 | - SmartTCPServer_for_testing, |
769 | - SmartTCPServer_for_testing_v2_only, |
770 | - ) |
771 | from bzrlib.tests import ( |
772 | - default_transport, |
773 | - multiply_scenarios, |
774 | - multiply_tests, |
775 | - ) |
776 | + default_transport, |
777 | + multiply_scenarios, |
778 | + multiply_tests, |
779 | + test_server, |
780 | + ) |
781 | from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir |
782 | -from bzrlib.transport.memory import MemoryServer |
783 | +from bzrlib.transport import memory |
784 | |
785 | |
786 | def formats_to_scenarios(formats, transport_server, transport_readonly_server, |
787 | @@ -91,14 +86,14 @@ |
788 | None) |
789 | format_scenarios.extend(formats_to_scenarios( |
790 | [('-default', RemoteRepositoryFormat())], |
791 | - SmartTCPServer_for_testing, |
792 | - ReadonlySmartTCPServer_for_testing, |
793 | - MemoryServer)) |
794 | + test_server.SmartTCPServer_for_testing, |
795 | + test_server.ReadonlySmartTCPServer_for_testing, |
796 | + memory.MemoryServer)) |
797 | format_scenarios.extend(formats_to_scenarios( |
798 | [('-v2', RemoteRepositoryFormat())], |
799 | - SmartTCPServer_for_testing_v2_only, |
800 | - ReadonlySmartTCPServer_for_testing_v2_only, |
801 | - MemoryServer)) |
802 | + test_server.SmartTCPServer_for_testing_v2_only, |
803 | + test_server.ReadonlySmartTCPServer_for_testing_v2_only, |
804 | + memory.MemoryServer)) |
805 | return format_scenarios |
806 | |
807 | |
808 | |
809 | === modified file 'bzrlib/tests/per_repository/test_repository.py' |
810 | --- bzrlib/tests/per_repository/test_repository.py 2010-02-10 19:20:57 +0000 |
811 | +++ bzrlib/tests/per_repository/test_repository.py 2010-02-11 09:31:16 +0000 |
812 | @@ -43,9 +43,10 @@ |
813 | pack_repo, |
814 | weaverepo, |
815 | ) |
816 | -from bzrlib.smart import server |
817 | -from bzrlib.tests import per_repository |
818 | -from bzrlib.transport.fakevfat import FakeVFATServer |
819 | +from bzrlib.tests import ( |
820 | + per_repository, |
821 | + test_server, |
822 | + ) |
823 | |
824 | |
825 | class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository): |
826 | @@ -823,7 +824,7 @@ |
827 | """Make a RemoteRepository object backed by a real repository that will |
828 | be created at the given path.""" |
829 | repo = self.make_repository(path, shared=shared) |
830 | - smart_server = server.SmartTCPServer_for_testing() |
831 | + smart_server = test_server.SmartTCPServer_for_testing() |
832 | self.start_server(smart_server, self.get_server()) |
833 | remote_transport = transport.get_transport( |
834 | smart_server.get_url()).clone(path) |
835 | @@ -1295,7 +1296,7 @@ |
836 | # about local disk layout/support. |
837 | if isinstance(self.repository_format, remote.RemoteRepositoryFormat): |
838 | return |
839 | - self.transport_server = FakeVFATServer |
840 | + self.transport_server = test_server.FakeVFATServer |
841 | FOO_ID = 'foo<:>ID' |
842 | REV_ID = 'revid-1' |
843 | # this makes a default format repository always, which is wrong: |
844 | |
845 | === modified file 'bzrlib/tests/per_repository/test_write_group.py' |
846 | --- bzrlib/tests/per_repository/test_write_group.py 2010-02-10 17:52:08 +0000 |
847 | +++ bzrlib/tests/per_repository/test_write_group.py 2010-02-11 09:31:16 +0000 |
848 | @@ -29,8 +29,11 @@ |
849 | tests, |
850 | versionedfile, |
851 | ) |
852 | -from bzrlib.transport import local, memory |
853 | -from bzrlib.tests import per_repository |
854 | +from bzrlib.tests import ( |
855 | + per_repository, |
856 | + test_server, |
857 | + ) |
858 | +from bzrlib.transport import memory |
859 | |
860 | |
861 | class TestWriteGroup(per_repository.TestCaseWithRepository): |
862 | @@ -114,7 +117,7 @@ |
863 | repo.unlock() |
864 | |
865 | def test_abort_write_group_does_not_raise_when_suppressed(self): |
866 | - if self.transport_server is local.LocalURLServer: |
867 | + if self.transport_server is test_server.LocalURLServer: |
868 | self.transport_server = None |
869 | self.vfs_transport_factory = memory.MemoryServer |
870 | repo = self.make_repository('repo') |
871 | |
872 | === modified file 'bzrlib/tests/per_transport.py' |
873 | --- bzrlib/tests/per_transport.py 2010-01-07 16:27:12 +0000 |
874 | +++ bzrlib/tests/per_transport.py 2010-02-11 09:31:16 +0000 |
875 | @@ -52,6 +52,7 @@ |
876 | TestNotApplicable, |
877 | multiply_tests, |
878 | ) |
879 | +from bzrlib.tests import test_server |
880 | from bzrlib.tests.test_transport import TestTransportImplementation |
881 | from bzrlib.transport import ( |
882 | ConnectedTransport, |
883 | @@ -170,8 +171,7 @@ |
884 | self.assertEqual(True, t.has_any(['b', 'b', 'b'])) |
885 | |
886 | def test_has_root_works(self): |
887 | - from bzrlib.smart import server |
888 | - if self.transport_server is server.SmartTCPServer_for_testing: |
889 | + if self.transport_server is test_server.SmartTCPServer_for_testing: |
890 | raise TestNotApplicable( |
891 | "SmartTCPServer_for_testing intentionally does not allow " |
892 | "access to /.") |
893 | |
894 | === modified file 'bzrlib/tests/stub_sftp.py' |
895 | --- bzrlib/tests/stub_sftp.py 2010-02-10 17:52:08 +0000 |
896 | +++ bzrlib/tests/stub_sftp.py 2010-02-11 09:31:16 +0000 |
897 | @@ -33,10 +33,10 @@ |
898 | urlutils, |
899 | ) |
900 | from bzrlib.transport import ( |
901 | - local, |
902 | - Server, |
903 | ssh, |
904 | ) |
905 | +from bzrlib.tests import test_server |
906 | + |
907 | |
908 | class StubServer (paramiko.ServerInterface): |
909 | |
910 | @@ -382,7 +382,7 @@ |
911 | return bytes_sent |
912 | |
913 | |
914 | -class SFTPServer(Server): |
915 | +class SFTPServer(test_server.TestServer): |
916 | """Common code for SFTP server facilities.""" |
917 | |
918 | def __init__(self, server_interface=StubServer): |
919 | @@ -436,7 +436,7 @@ |
920 | # XXX: TODO: make sftpserver back onto backing_server rather than local |
921 | # disk. |
922 | if not (backing_server is None or |
923 | - isinstance(backing_server, local.LocalURLServer)): |
924 | + isinstance(backing_server, test_server.LocalURLServer)): |
925 | raise AssertionError( |
926 | "backing_server should not be %r, because this can only serve the " |
927 | "local current working directory." % (backing_server,)) |
928 | |
929 | === modified file 'bzrlib/tests/test_bzrdir.py' |
930 | --- bzrlib/tests/test_bzrdir.py 2010-01-08 07:34:31 +0000 |
931 | +++ bzrlib/tests/test_bzrdir.py 2010-02-11 09:31:16 +0000 |
932 | @@ -50,9 +50,11 @@ |
933 | http_utils, |
934 | ) |
935 | from bzrlib.tests.test_http import TestWithTransport_pycurl |
936 | -from bzrlib.transport import get_transport |
937 | +from bzrlib.transport import ( |
938 | + get_transport, |
939 | + memory, |
940 | + ) |
941 | from bzrlib.transport.http._urllib import HttpTransport_urllib |
942 | -from bzrlib.transport.memory import MemoryServer |
943 | from bzrlib.transport.nosmart import NoSmartTransportDecorator |
944 | from bzrlib.transport.readonly import ReadonlyTransportDecorator |
945 | from bzrlib.repofmt import knitrepo, weaverepo, pack_repo |
946 | @@ -354,7 +356,7 @@ |
947 | |
948 | def test_create_branch_convenience_root(self): |
949 | """Creating a branch at the root of a fs should work.""" |
950 | - self.vfs_transport_factory = MemoryServer |
951 | + self.vfs_transport_factory = memory.MemoryServer |
952 | # outside a repo the default convenience output is a repo+branch_tree |
953 | format = bzrdir.format_registry.make_bzrdir('knit') |
954 | branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(), |
955 | @@ -565,7 +567,7 @@ |
956 | |
957 | def setUp(self): |
958 | super(ChrootedTests, self).setUp() |
959 | - if not self.vfs_transport_factory == MemoryServer: |
960 | + if not self.vfs_transport_factory == memory.MemoryServer: |
961 | self.transport_readonly_server = http_server.HttpServer |
962 | |
963 | def local_branch_path(self, branch): |
964 | @@ -1049,7 +1051,7 @@ |
965 | |
966 | def setUp(self): |
967 | super(NonLocalTests, self).setUp() |
968 | - self.vfs_transport_factory = MemoryServer |
969 | + self.vfs_transport_factory = memory.MemoryServer |
970 | |
971 | def test_create_branch_convenience(self): |
972 | # outside a repo the default convenience output is a repo+branch_tree |
973 | |
974 | === modified file 'bzrlib/tests/test_remote.py' |
975 | --- bzrlib/tests/test_remote.py 2010-01-25 17:48:22 +0000 |
976 | +++ bzrlib/tests/test_remote.py 2010-02-11 09:31:16 +0000 |
977 | @@ -54,13 +54,14 @@ |
978 | ) |
979 | from bzrlib.repofmt import groupcompress_repo, pack_repo |
980 | from bzrlib.revision import NULL_REVISION |
981 | -from bzrlib.smart import server, medium |
982 | +from bzrlib.smart import medium |
983 | from bzrlib.smart.client import _SmartClient |
984 | from bzrlib.smart.repository import SmartServerRepositoryGetParentMap |
985 | from bzrlib.tests import ( |
986 | condition_isinstance, |
987 | split_suite_by_condition, |
988 | multiply_tests, |
989 | + test_server, |
990 | ) |
991 | from bzrlib.transport import get_transport |
992 | from bzrlib.transport.memory import MemoryTransport |
993 | @@ -75,9 +76,9 @@ |
994 | standard_tests, condition_isinstance(BasicRemoteObjectTests)) |
995 | smart_server_version_scenarios = [ |
996 | ('HPSS-v2', |
997 | - {'transport_server': server.SmartTCPServer_for_testing_v2_only}), |
998 | + {'transport_server': test_server.SmartTCPServer_for_testing_v2_only}), |
999 | ('HPSS-v3', |
1000 | - {'transport_server': server.SmartTCPServer_for_testing})] |
1001 | + {'transport_server': test_server.SmartTCPServer_for_testing})] |
1002 | return multiply_tests(to_adapt, smart_server_version_scenarios, result) |
1003 | |
1004 | |
1005 | @@ -2074,7 +2075,7 @@ |
1006 | |
1007 | def test_allows_new_revisions(self): |
1008 | """get_parent_map's results can be updated by commit.""" |
1009 | - smart_server = server.SmartTCPServer_for_testing() |
1010 | + smart_server = test_server.SmartTCPServer_for_testing() |
1011 | self.start_server(smart_server) |
1012 | self.make_branch('branch') |
1013 | branch = Branch.open(smart_server.get_url() + '/branch') |
1014 | @@ -2622,7 +2623,7 @@ |
1015 | """RemoteRepository.copy_content_into optimizations""" |
1016 | |
1017 | def test_copy_content_remote_to_local(self): |
1018 | - self.transport_server = server.SmartTCPServer_for_testing |
1019 | + self.transport_server = test_server.SmartTCPServer_for_testing |
1020 | src_repo = self.make_repository('repo1') |
1021 | src_repo = repository.Repository.open(self.get_url('repo1')) |
1022 | # At the moment the tarball-based copy_content_into can't write back |
1023 | @@ -2941,7 +2942,7 @@ |
1024 | stacked_branch = self.make_branch('stacked', format='1.9') |
1025 | stacked_branch.set_stacked_on_url('../base') |
1026 | # start a server looking at this |
1027 | - smart_server = server.SmartTCPServer_for_testing() |
1028 | + smart_server = test_server.SmartTCPServer_for_testing() |
1029 | self.start_server(smart_server) |
1030 | remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked') |
1031 | # can get its branch and repository |
1032 | @@ -3103,7 +3104,7 @@ |
1033 | super(TestRemoteBranchEffort, self).setUp() |
1034 | # Create a smart server that publishes whatever the backing VFS server |
1035 | # does. |
1036 | - self.smart_server = server.SmartTCPServer_for_testing() |
1037 | + self.smart_server = test_server.SmartTCPServer_for_testing() |
1038 | self.start_server(self.smart_server, self.get_server()) |
1039 | # Log all HPSS calls into self.hpss_calls. |
1040 | _SmartClient.hooks.install_named_hook( |
1041 | |
1042 | === modified file 'bzrlib/tests/test_repository.py' |
1043 | --- bzrlib/tests/test_repository.py 2010-01-31 12:10:40 +0000 |
1044 | +++ bzrlib/tests/test_repository.py 2010-02-11 09:31:16 +0000 |
1045 | @@ -51,7 +51,6 @@ |
1046 | fakenfs, |
1047 | get_transport, |
1048 | ) |
1049 | -from bzrlib.transport.memory import MemoryServer |
1050 | from bzrlib import ( |
1051 | bencode, |
1052 | bzrdir, |
1053 | |
1054 | === modified file 'bzrlib/tests/test_selftest.py' |
1055 | --- bzrlib/tests/test_selftest.py 2010-02-10 17:52:08 +0000 |
1056 | +++ bzrlib/tests/test_selftest.py 2010-02-11 09:31:16 +0000 |
1057 | @@ -64,11 +64,12 @@ |
1058 | features, |
1059 | stub_sftp, |
1060 | test_lsprof, |
1061 | + test_server, |
1062 | test_sftp_transport, |
1063 | TestUtil, |
1064 | ) |
1065 | from bzrlib.trace import note |
1066 | -from bzrlib.transport.memory import MemoryServer, MemoryTransport |
1067 | +from bzrlib.transport import memory |
1068 | from bzrlib.version import _get_bzr_source_tree |
1069 | |
1070 | |
1071 | @@ -622,9 +623,8 @@ |
1072 | |
1073 | def test_get_readonly_url_none(self): |
1074 | from bzrlib.transport import get_transport |
1075 | - from bzrlib.transport.memory import MemoryServer |
1076 | from bzrlib.transport.readonly import ReadonlyTransportDecorator |
1077 | - self.vfs_transport_factory = MemoryServer |
1078 | + self.vfs_transport_factory = memory.MemoryServer |
1079 | self.transport_readonly_server = None |
1080 | # calling get_readonly_transport() constructs a decorator on the url |
1081 | # for the server |
1082 | @@ -639,9 +639,8 @@ |
1083 | def test_get_readonly_url_http(self): |
1084 | from bzrlib.tests.http_server import HttpServer |
1085 | from bzrlib.transport import get_transport |
1086 | - from bzrlib.transport.local import LocalURLServer |
1087 | from bzrlib.transport.http import HttpTransportBase |
1088 | - self.transport_server = LocalURLServer |
1089 | + self.transport_server = test_server.LocalURLServer |
1090 | self.transport_readonly_server = HttpServer |
1091 | # calling get_readonly_transport() gives us a HTTP server instance. |
1092 | url = self.get_readonly_url() |
1093 | @@ -678,13 +677,13 @@ |
1094 | |
1095 | def setUp(self): |
1096 | super(TestTestCaseTransports, self).setUp() |
1097 | - self.vfs_transport_factory = MemoryServer |
1098 | + self.vfs_transport_factory = memory.MemoryServer |
1099 | |
1100 | def test_make_bzrdir_preserves_transport(self): |
1101 | t = self.get_transport() |
1102 | result_bzrdir = self.make_bzrdir('subdir') |
1103 | self.assertIsInstance(result_bzrdir.transport, |
1104 | - MemoryTransport) |
1105 | + memory.MemoryTransport) |
1106 | # should not be on disk, should only be in memory |
1107 | self.failIfExists('subdir') |
1108 | |
1109 | @@ -1470,7 +1469,7 @@ |
1110 | # permitted. |
1111 | # Manually set one up (TestCase doesn't and shouldn't provide magic |
1112 | # machinery) |
1113 | - transport_server = MemoryServer() |
1114 | + transport_server = memory.MemoryServer() |
1115 | transport_server.start_server() |
1116 | self.addCleanup(transport_server.stop_server) |
1117 | t = transport.get_transport(transport_server.get_url()) |
1118 | @@ -1558,7 +1557,7 @@ |
1119 | result.calls) |
1120 | |
1121 | def test_start_server_registers_url(self): |
1122 | - transport_server = MemoryServer() |
1123 | + transport_server = memory.MemoryServer() |
1124 | # A little strict, but unlikely to be changed soon. |
1125 | self.assertEqual([], self._bzr_selftest_roots) |
1126 | self.start_server(transport_server) |
1127 | @@ -1805,8 +1804,7 @@ |
1128 | # make_branch_and_tree has to use local branch and repositories |
1129 | # when the vfs transport and local disk are colocated, even if |
1130 | # a different transport is in use for url generation. |
1131 | - from bzrlib.transport.fakevfat import FakeVFATServer |
1132 | - self.transport_server = FakeVFATServer |
1133 | + self.transport_server = test_server.FakeVFATServer |
1134 | self.assertFalse(self.get_url('t1').startswith('file://')) |
1135 | tree = self.make_branch_and_tree('t1') |
1136 | base = tree.bzrdir.root_transport.base |
1137 | @@ -1952,7 +1950,7 @@ |
1138 | self.check_transport_set(stub_sftp.SFTPAbsoluteServer) |
1139 | |
1140 | def test_transport_memory(self): |
1141 | - self.check_transport_set(bzrlib.transport.memory.MemoryServer) |
1142 | + self.check_transport_set(memory.MemoryServer) |
1143 | |
1144 | |
1145 | class TestSelftestWithIdList(tests.TestCaseInTempDir, SelfTestHelper): |
1146 | @@ -2623,7 +2621,7 @@ |
1147 | # Running bzr in blackbox mode, normal/expected/user errors should be |
1148 | # caught in the regular way and turned into an error message plus exit |
1149 | # code. |
1150 | - transport_server = MemoryServer() |
1151 | + transport_server = memory.MemoryServer() |
1152 | transport_server.start_server() |
1153 | self.addCleanup(transport_server.stop_server) |
1154 | url = transport_server.get_url() |
1155 | |
1156 | === added file 'bzrlib/tests/test_server.py' |
1157 | --- bzrlib/tests/test_server.py 1970-01-01 00:00:00 +0000 |
1158 | +++ bzrlib/tests/test_server.py 2010-02-11 09:31:16 +0000 |
1159 | @@ -0,0 +1,312 @@ |
1160 | +# Copyright (C) 2005, 2006, 2007, 2008, 2010 Canonical Ltd |
1161 | +# |
1162 | +# This program is free software; you can redistribute it and/or modify |
1163 | +# it under the terms of the GNU General Public License as published by |
1164 | +# the Free Software Foundation; either version 2 of the License, or |
1165 | +# (at your option) any later version. |
1166 | +# |
1167 | +# This program is distributed in the hope that it will be useful, |
1168 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1169 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1170 | +# GNU General Public License for more details. |
1171 | +# |
1172 | +# You should have received a copy of the GNU General Public License |
1173 | +# along with this program; if not, write to the Free Software |
1174 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1175 | + |
1176 | +from bzrlib import ( |
1177 | + transport, |
1178 | + urlutils, |
1179 | + ) |
1180 | +from bzrlib.transport import ( |
1181 | + chroot, |
1182 | + pathfilter, |
1183 | + ) |
1184 | +from bzrlib.smart import server |
1185 | + |
1186 | + |
1187 | +class TestServer(transport.Server): |
1188 | + """A Transport Server dedicated to tests. |
1189 | + |
1190 | + The TestServer interface provides a server for a given transport. We use |
1191 | + these servers as loopback testing tools. For any given transport the |
1192 | + Servers it provides must either allow writing, or serve the contents |
1193 | + of os.getcwdu() at the time start_server is called. |
1194 | + |
1195 | + Note that these are real servers - they must implement all the things |
1196 | + that we want bzr transports to take advantage of. |
1197 | + """ |
1198 | + |
1199 | + def get_url(self): |
1200 | + """Return a url for this server. |
1201 | + |
1202 | + If the transport does not represent a disk directory (i.e. it is |
1203 | + a database like svn, or a memory only transport, it should return |
1204 | + a connection to a newly established resource for this Server. |
1205 | + Otherwise it should return a url that will provide access to the path |
1206 | + that was os.getcwdu() when start_server() was called. |
1207 | + |
1208 | + Subsequent calls will return the same resource. |
1209 | + """ |
1210 | + raise NotImplementedError |
1211 | + |
1212 | + def get_bogus_url(self): |
1213 | + """Return a url for this protocol, that will fail to connect. |
1214 | + |
1215 | + This may raise NotImplementedError to indicate that this server cannot |
1216 | + provide bogus urls. |
1217 | + """ |
1218 | + raise NotImplementedError |
1219 | + |
1220 | + |
1221 | +class LocalURLServer(TestServer): |
1222 | + """A pretend server for local transports, using file:// urls. |
1223 | + |
1224 | + Of course no actual server is required to access the local filesystem, so |
1225 | + this just exists to tell the test code how to get to it. |
1226 | + """ |
1227 | + |
1228 | + def start_server(self): |
1229 | + pass |
1230 | + |
1231 | + def get_url(self): |
1232 | + """See Transport.Server.get_url.""" |
1233 | + return urlutils.local_path_to_url('') |
1234 | + |
1235 | + |
1236 | +class DecoratorServer(TestServer): |
1237 | + """Server for the TransportDecorator for testing with. |
1238 | + |
1239 | + To use this when subclassing TransportDecorator, override override the |
1240 | + get_decorator_class method. |
1241 | + """ |
1242 | + |
1243 | + def start_server(self, server=None): |
1244 | + """See bzrlib.transport.Server.start_server. |
1245 | + |
1246 | + :server: decorate the urls given by server. If not provided a |
1247 | + LocalServer is created. |
1248 | + """ |
1249 | + if server is not None: |
1250 | + self._made_server = False |
1251 | + self._server = server |
1252 | + else: |
1253 | + self._made_server = True |
1254 | + self._server = LocalURLServer() |
1255 | + self._server.start_server() |
1256 | + |
1257 | + def stop_server(self): |
1258 | + if self._made_server: |
1259 | + self._server.stop_server() |
1260 | + |
1261 | + def get_decorator_class(self): |
1262 | + """Return the class of the decorators we should be constructing.""" |
1263 | + raise NotImplementedError(self.get_decorator_class) |
1264 | + |
1265 | + def get_url_prefix(self): |
1266 | + """What URL prefix does this decorator produce?""" |
1267 | + return self.get_decorator_class()._get_url_prefix() |
1268 | + |
1269 | + def get_bogus_url(self): |
1270 | + """See bzrlib.transport.Server.get_bogus_url.""" |
1271 | + return self.get_url_prefix() + self._server.get_bogus_url() |
1272 | + |
1273 | + def get_url(self): |
1274 | + """See bzrlib.transport.Server.get_url.""" |
1275 | + return self.get_url_prefix() + self._server.get_url() |
1276 | + |
1277 | + |
1278 | +class BrokenRenameServer(DecoratorServer): |
1279 | + """Server for the BrokenRenameTransportDecorator for testing with.""" |
1280 | + |
1281 | + def get_decorator_class(self): |
1282 | + from bzrlib.transport import brokenrename |
1283 | + return brokenrename.BrokenRenameTransportDecorator |
1284 | + |
1285 | + |
1286 | +class FakeNFSServer(DecoratorServer): |
1287 | + """Server for the FakeNFSTransportDecorator for testing with.""" |
1288 | + |
1289 | + def get_decorator_class(self): |
1290 | + from bzrlib.transport import fakenfs |
1291 | + return fakenfs.FakeNFSTransportDecorator |
1292 | + |
1293 | + |
1294 | +class FakeVFATServer(DecoratorServer): |
1295 | + """A server that suggests connections through FakeVFATTransportDecorator |
1296 | + |
1297 | + For use in testing. |
1298 | + """ |
1299 | + |
1300 | + def get_decorator_class(self): |
1301 | + from bzrlib.transport import fakevfat |
1302 | + return fakevfat.FakeVFATTransportDecorator |
1303 | + |
1304 | + |
1305 | +class LogDecoratorServer(DecoratorServer): |
1306 | + """Server for testing.""" |
1307 | + |
1308 | + def get_decorator_class(self): |
1309 | + from bzrlib.transport import log |
1310 | + return log.TransportLogDecorator |
1311 | + |
1312 | + |
1313 | +class NoSmartTransportServer(DecoratorServer): |
1314 | + """Server for the NoSmartTransportDecorator for testing with.""" |
1315 | + |
1316 | + def get_decorator_class(self): |
1317 | + from bzrlib.transport import nosmart |
1318 | + return nosmart.NoSmartTransportDecorator |
1319 | + |
1320 | + |
1321 | +class ReadonlyServer(DecoratorServer): |
1322 | + """Server for the ReadonlyTransportDecorator for testing with.""" |
1323 | + |
1324 | + def get_decorator_class(self): |
1325 | + from bzrlib.transport import readonly |
1326 | + return readonly.ReadonlyTransportDecorator |
1327 | + |
1328 | + |
1329 | +class TraceServer(DecoratorServer): |
1330 | + """Server for the TransportTraceDecorator for testing with.""" |
1331 | + |
1332 | + def get_decorator_class(self): |
1333 | + from bzrlib.transport import trace |
1334 | + return trace.TransportTraceDecorator |
1335 | + |
1336 | + |
1337 | +class UnlistableServer(DecoratorServer): |
1338 | + """Server for the UnlistableTransportDecorator for testing with.""" |
1339 | + |
1340 | + def get_decorator_class(self): |
1341 | + from bzrlib.transport import unlistable |
1342 | + return unlistable.UnlistableTransportDecorator |
1343 | + |
1344 | + |
1345 | +class TestingPathFilteringServer(pathfilter.PathFilteringServer): |
1346 | + |
1347 | + def __init__(self): |
1348 | + """TestingPathFilteringServer is not usable until start_server |
1349 | + is called.""" |
1350 | + |
1351 | + def start_server(self, backing_server=None): |
1352 | + """Setup the Chroot on backing_server.""" |
1353 | + if backing_server is not None: |
1354 | + self.backing_transport = transport.get_transport( |
1355 | + backing_server.get_url()) |
1356 | + else: |
1357 | + self.backing_transport = transport.get_transport('.') |
1358 | + self.backing_transport.clone('added-by-filter').ensure_base() |
1359 | + self.filter_func = lambda x: 'added-by-filter/' + x |
1360 | + super(TestingPathFilteringServer, self).start_server() |
1361 | + |
1362 | + def get_bogus_url(self): |
1363 | + raise NotImplementedError |
1364 | + |
1365 | + |
1366 | +class TestingChrootServer(chroot.ChrootServer): |
1367 | + |
1368 | + def __init__(self): |
1369 | + """TestingChrootServer is not usable until start_server is called.""" |
1370 | + super(TestingChrootServer, self).__init__(None) |
1371 | + |
1372 | + def start_server(self, backing_server=None): |
1373 | + """Setup the Chroot on backing_server.""" |
1374 | + if backing_server is not None: |
1375 | + self.backing_transport = transport.get_transport( |
1376 | + backing_server.get_url()) |
1377 | + else: |
1378 | + self.backing_transport = transport.get_transport('.') |
1379 | + super(TestingChrootServer, self).start_server() |
1380 | + |
1381 | + def get_bogus_url(self): |
1382 | + raise NotImplementedError |
1383 | + |
1384 | + |
1385 | +class SmartTCPServer_for_testing(server.SmartTCPServer): |
1386 | + """Server suitable for use by transport tests. |
1387 | + |
1388 | + This server is backed by the process's cwd. |
1389 | + """ |
1390 | + |
1391 | + def __init__(self, thread_name_suffix=''): |
1392 | + super(SmartTCPServer_for_testing, self).__init__(None) |
1393 | + self.client_path_extra = None |
1394 | + self.thread_name_suffix = thread_name_suffix |
1395 | + |
1396 | + def get_backing_transport(self, backing_transport_server): |
1397 | + """Get a backing transport from a server we are decorating.""" |
1398 | + return transport.get_transport(backing_transport_server.get_url()) |
1399 | + |
1400 | + def start_server(self, backing_transport_server=None, |
1401 | + client_path_extra='/extra/'): |
1402 | + """Set up server for testing. |
1403 | + |
1404 | + :param backing_transport_server: backing server to use. If not |
1405 | + specified, a LocalURLServer at the current working directory will |
1406 | + be used. |
1407 | + :param client_path_extra: a path segment starting with '/' to append to |
1408 | + the root URL for this server. For instance, a value of '/foo/bar/' |
1409 | + will mean the root of the backing transport will be published at a |
1410 | + URL like `bzr://127.0.0.1:nnnn/foo/bar/`, rather than |
1411 | + `bzr://127.0.0.1:nnnn/`. Default value is `extra`, so that tests |
1412 | + by default will fail unless they do the necessary path translation. |
1413 | + """ |
1414 | + if not client_path_extra.startswith('/'): |
1415 | + raise ValueError(client_path_extra) |
1416 | + from bzrlib.transport.chroot import ChrootServer |
1417 | + if backing_transport_server is None: |
1418 | + backing_transport_server = LocalURLServer() |
1419 | + self.chroot_server = ChrootServer( |
1420 | + self.get_backing_transport(backing_transport_server)) |
1421 | + self.chroot_server.start_server() |
1422 | + self.backing_transport = transport.get_transport( |
1423 | + self.chroot_server.get_url()) |
1424 | + self.root_client_path = self.client_path_extra = client_path_extra |
1425 | + self.start_background_thread(self.thread_name_suffix) |
1426 | + |
1427 | + def stop_server(self): |
1428 | + self.stop_background_thread() |
1429 | + self.chroot_server.stop_server() |
1430 | + |
1431 | + def get_url(self): |
1432 | + url = super(SmartTCPServer_for_testing, self).get_url() |
1433 | + return url[:-1] + self.client_path_extra |
1434 | + |
1435 | + def get_bogus_url(self): |
1436 | + """Return a URL which will fail to connect""" |
1437 | + return 'bzr://127.0.0.1:1/' |
1438 | + |
1439 | + |
1440 | +class ReadonlySmartTCPServer_for_testing(SmartTCPServer_for_testing): |
1441 | + """Get a readonly server for testing.""" |
1442 | + |
1443 | + def get_backing_transport(self, backing_transport_server): |
1444 | + """Get a backing transport from a server we are decorating.""" |
1445 | + url = 'readonly+' + backing_transport_server.get_url() |
1446 | + return transport.get_transport(url) |
1447 | + |
1448 | + |
1449 | +class SmartTCPServer_for_testing_v2_only(SmartTCPServer_for_testing): |
1450 | + """A variation of SmartTCPServer_for_testing that limits the client to |
1451 | + using RPCs in protocol v2 (i.e. bzr <= 1.5). |
1452 | + """ |
1453 | + |
1454 | + def get_url(self): |
1455 | + url = super(SmartTCPServer_for_testing_v2_only, self).get_url() |
1456 | + url = 'bzr-v2://' + url[len('bzr://'):] |
1457 | + return url |
1458 | + |
1459 | + |
1460 | +class ReadonlySmartTCPServer_for_testing_v2_only( |
1461 | + SmartTCPServer_for_testing_v2_only): |
1462 | + """Get a readonly server for testing.""" |
1463 | + |
1464 | + def get_backing_transport(self, backing_transport_server): |
1465 | + """Get a backing transport from a server we are decorating.""" |
1466 | + url = 'readonly+' + backing_transport_server.get_url() |
1467 | + return transport.get_transport(url) |
1468 | + |
1469 | + |
1470 | + |
1471 | + |
1472 | |
1473 | === modified file 'bzrlib/tests/test_smart.py' |
1474 | --- bzrlib/tests/test_smart.py 2010-02-10 17:52:08 +0000 |
1475 | +++ bzrlib/tests/test_smart.py 2010-02-11 09:31:16 +0000 |
1476 | @@ -48,9 +48,9 @@ |
1477 | server, |
1478 | vfs, |
1479 | ) |
1480 | +from bzrlib.tests import test_server |
1481 | from bzrlib.transport import ( |
1482 | chroot, |
1483 | - local, |
1484 | memory, |
1485 | ) |
1486 | |
1487 | @@ -106,7 +106,7 @@ |
1488 | self.transport_server = self.make_transport_server |
1489 | |
1490 | def make_transport_server(self): |
1491 | - return server.SmartTCPServer_for_testing('-' + self.id()) |
1492 | + return test_server.SmartTCPServer_for_testing('-' + self.id()) |
1493 | |
1494 | def get_smart_medium(self): |
1495 | """Get a smart medium to use in tests.""" |
1496 | @@ -489,7 +489,7 @@ |
1497 | class TestSmartServerRequestOpenBzrDir_2_1_disk(TestCaseWithChrootedTransport): |
1498 | |
1499 | def test_present_with_workingtree(self): |
1500 | - self.vfs_transport_factory = local.LocalURLServer |
1501 | + self.vfs_transport_factory = test_server.LocalURLServer |
1502 | backing = self.get_transport() |
1503 | request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing) |
1504 | bd = self.make_bzrdir('.') |
1505 | @@ -520,7 +520,7 @@ |
1506 | |
1507 | def test_branch_reference(self): |
1508 | """When there is a branch reference, the reference URL is returned.""" |
1509 | - self.vfs_transport_factory = local.LocalURLServer |
1510 | + self.vfs_transport_factory = test_server.LocalURLServer |
1511 | backing = self.get_transport() |
1512 | request = smart_dir.SmartServerRequestOpenBranch(backing) |
1513 | branch = self.make_branch('branch') |
1514 | @@ -561,7 +561,7 @@ |
1515 | |
1516 | def test_branch_reference(self): |
1517 | """When there is a branch reference, the reference URL is returned.""" |
1518 | - self.vfs_transport_factory = local.LocalURLServer |
1519 | + self.vfs_transport_factory = test_server.LocalURLServer |
1520 | backing = self.get_transport() |
1521 | request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
1522 | branch = self.make_branch('branch') |
1523 | @@ -624,7 +624,7 @@ |
1524 | |
1525 | def test_branch_reference(self): |
1526 | """When there is a branch reference, the reference URL is returned.""" |
1527 | - self.vfs_transport_factory = local.LocalURLServer |
1528 | + self.vfs_transport_factory = test_server.LocalURLServer |
1529 | backing = self.get_transport() |
1530 | request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
1531 | branch = self.make_branch('branch') |
1532 | |
1533 | === modified file 'bzrlib/tests/test_transport.py' |
1534 | --- bzrlib/tests/test_transport.py 2010-02-10 17:52:08 +0000 |
1535 | +++ bzrlib/tests/test_transport.py 2010-02-11 09:31:16 +0000 |
1536 | @@ -36,7 +36,10 @@ |
1537 | pathfilter, |
1538 | readonly, |
1539 | ) |
1540 | -from bzrlib.tests import features |
1541 | +from bzrlib.tests import ( |
1542 | + features, |
1543 | + test_server, |
1544 | + ) |
1545 | |
1546 | |
1547 | # TODO: Should possibly split transport-specific tests into their own files. |
1548 | @@ -593,7 +596,7 @@ |
1549 | |
1550 | def test_fakenfs_server_default(self): |
1551 | # a FakeNFSServer() should bring up a local relpath server for itself |
1552 | - server = fakenfs.FakeNFSServer() |
1553 | + server = test_server.FakeNFSServer() |
1554 | self.start_server(server) |
1555 | # the url should be decorated appropriately |
1556 | self.assertStartsWith(server.get_url(), 'fakenfs+') |
1557 | |
1558 | === modified file 'bzrlib/transport/__init__.py' |
1559 | --- bzrlib/transport/__init__.py 2010-01-07 03:03:01 +0000 |
1560 | +++ bzrlib/transport/__init__.py 2010-02-11 09:31:16 +0000 |
1561 | @@ -1663,13 +1663,7 @@ |
1562 | class Server(object): |
1563 | """A Transport Server. |
1564 | |
1565 | - The Server interface provides a server for a given transport. We use |
1566 | - these servers as loopback testing tools. For any given transport the |
1567 | - Servers it provides must either allow writing, or serve the contents |
1568 | - of os.getcwdu() at the time start_server is called. |
1569 | - |
1570 | - Note that these are real servers - they must implement all the things |
1571 | - that we want bzr transports to take advantage of. |
1572 | + The Server interface provides a server for a given transport type. |
1573 | """ |
1574 | |
1575 | def start_server(self): |
1576 | @@ -1678,27 +1672,6 @@ |
1577 | def stop_server(self): |
1578 | """Remove the server and cleanup any resources it owns.""" |
1579 | |
1580 | - def get_url(self): |
1581 | - """Return a url for this server. |
1582 | - |
1583 | - If the transport does not represent a disk directory (i.e. it is |
1584 | - a database like svn, or a memory only transport, it should return |
1585 | - a connection to a newly established resource for this Server. |
1586 | - Otherwise it should return a url that will provide access to the path |
1587 | - that was os.getcwdu() when start_server() was called. |
1588 | - |
1589 | - Subsequent calls will return the same resource. |
1590 | - """ |
1591 | - raise NotImplementedError |
1592 | - |
1593 | - def get_bogus_url(self): |
1594 | - """Return a url for this protocol, that will fail to connect. |
1595 | - |
1596 | - This may raise NotImplementedError to indicate that this server cannot |
1597 | - provide bogus urls. |
1598 | - """ |
1599 | - raise NotImplementedError |
1600 | - |
1601 | |
1602 | # None is the default transport, for things with no url scheme |
1603 | register_transport_proto('file://', |
1604 | |
1605 | === modified file 'bzrlib/transport/brokenrename.py' |
1606 | --- bzrlib/transport/brokenrename.py 2009-03-23 14:59:43 +0000 |
1607 | +++ bzrlib/transport/brokenrename.py 2010-02-11 09:31:16 +0000 |
1608 | @@ -23,10 +23,10 @@ |
1609 | errors, |
1610 | urlutils, |
1611 | ) |
1612 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
1613 | - |
1614 | - |
1615 | -class BrokenRenameTransportDecorator(TransportDecorator): |
1616 | +from bzrlib.transport import decorator |
1617 | + |
1618 | + |
1619 | +class BrokenRenameTransportDecorator(decorator.TransportDecorator): |
1620 | """A transport that fails to detect clashing renames""" |
1621 | |
1622 | @classmethod |
1623 | @@ -46,13 +46,6 @@ |
1624 | return |
1625 | |
1626 | |
1627 | -class BrokenRenameServer(DecoratorServer): |
1628 | - """Server for the BrokenRenameTransportDecorator for testing with.""" |
1629 | - |
1630 | - def get_decorator_class(self): |
1631 | - return BrokenRenameTransportDecorator |
1632 | - |
1633 | - |
1634 | def get_test_permutations(): |
1635 | """Return the permutations to be used in testing.""" |
1636 | # we don't use this for general testing, only for the tests that |
1637 | |
1638 | === modified file 'bzrlib/transport/chroot.py' |
1639 | --- bzrlib/transport/chroot.py 2010-01-07 03:03:01 +0000 |
1640 | +++ bzrlib/transport/chroot.py 2010-02-11 09:31:16 +0000 |
1641 | @@ -65,21 +65,7 @@ |
1642 | return self._relpath_from_server_root(relpath) |
1643 | |
1644 | |
1645 | -class TestingChrootServer(ChrootServer): |
1646 | - |
1647 | - def __init__(self): |
1648 | - """TestingChrootServer is not usable until start_server is called.""" |
1649 | - ChrootServer.__init__(self, None) |
1650 | - |
1651 | - def start_server(self, backing_server=None): |
1652 | - """Setup the Chroot on backing_server.""" |
1653 | - if backing_server is not None: |
1654 | - self.backing_transport = get_transport(backing_server.get_url()) |
1655 | - else: |
1656 | - self.backing_transport = get_transport('.') |
1657 | - ChrootServer.start_server(self) |
1658 | - |
1659 | - |
1660 | def get_test_permutations(): |
1661 | """Return the permutations to be used in testing.""" |
1662 | - return [(ChrootTransport, TestingChrootServer)] |
1663 | + from bzrlib.tests import test_server |
1664 | + return [(ChrootTransport, test_server.TestingChrootServer)] |
1665 | |
1666 | === modified file 'bzrlib/transport/decorator.py' |
1667 | --- bzrlib/transport/decorator.py 2010-01-07 03:03:01 +0000 |
1668 | +++ bzrlib/transport/decorator.py 2010-02-11 09:31:16 +0000 |
1669 | @@ -177,49 +177,6 @@ |
1670 | return None |
1671 | |
1672 | |
1673 | -class DecoratorServer(Server): |
1674 | - """Server for the TransportDecorator for testing with. |
1675 | - |
1676 | - To use this when subclassing TransportDecorator, override override the |
1677 | - get_decorator_class method. |
1678 | - """ |
1679 | - |
1680 | - def start_server(self, server=None): |
1681 | - """See bzrlib.transport.Server.start_server. |
1682 | - |
1683 | - :server: decorate the urls given by server. If not provided a |
1684 | - LocalServer is created. |
1685 | - """ |
1686 | - if server is not None: |
1687 | - self._made_server = False |
1688 | - self._server = server |
1689 | - else: |
1690 | - from bzrlib.transport.local import LocalURLServer |
1691 | - self._made_server = True |
1692 | - self._server = LocalURLServer() |
1693 | - self._server.start_server() |
1694 | - |
1695 | - def stop_server(self): |
1696 | - if self._made_server: |
1697 | - self._server.stop_server() |
1698 | - |
1699 | - def get_decorator_class(self): |
1700 | - """Return the class of the decorators we should be constructing.""" |
1701 | - raise NotImplementedError(self.get_decorator_class) |
1702 | - |
1703 | - def get_url_prefix(self): |
1704 | - """What URL prefix does this decorator produce?""" |
1705 | - return self.get_decorator_class()._get_url_prefix() |
1706 | - |
1707 | - def get_bogus_url(self): |
1708 | - """See bzrlib.transport.Server.get_bogus_url.""" |
1709 | - return self.get_url_prefix() + self._server.get_bogus_url() |
1710 | - |
1711 | - def get_url(self): |
1712 | - """See bzrlib.transport.Server.get_url.""" |
1713 | - return self.get_url_prefix() + self._server.get_url() |
1714 | - |
1715 | - |
1716 | def get_test_permutations(): |
1717 | """Return the permutations to be used in testing. |
1718 | |
1719 | |
1720 | === modified file 'bzrlib/transport/fakenfs.py' |
1721 | --- bzrlib/transport/fakenfs.py 2009-03-23 14:59:43 +0000 |
1722 | +++ bzrlib/transport/fakenfs.py 2010-02-11 09:31:16 +0000 |
1723 | @@ -28,10 +28,10 @@ |
1724 | errors, |
1725 | urlutils, |
1726 | ) |
1727 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
1728 | - |
1729 | - |
1730 | -class FakeNFSTransportDecorator(TransportDecorator): |
1731 | +from bzrlib.transport import decorator |
1732 | + |
1733 | + |
1734 | +class FakeNFSTransportDecorator(decorator.TransportDecorator): |
1735 | """A transport that behaves like NFS, for testing""" |
1736 | |
1737 | @classmethod |
1738 | @@ -62,14 +62,7 @@ |
1739 | return self._decorated.delete(relpath) |
1740 | |
1741 | |
1742 | -class FakeNFSServer(DecoratorServer): |
1743 | - """Server for the FakeNFSTransportDecorator for testing with.""" |
1744 | - |
1745 | - def get_decorator_class(self): |
1746 | - return FakeNFSTransportDecorator |
1747 | - |
1748 | - |
1749 | def get_test_permutations(): |
1750 | """Return the permutations to be used in testing.""" |
1751 | - return [(FakeNFSTransportDecorator, FakeNFSServer), |
1752 | - ] |
1753 | + from bzrlib.tests import test_server |
1754 | + return [(FakeNFSTransportDecorator, test_server.FakeNFSServer),] |
1755 | |
1756 | === modified file 'bzrlib/transport/fakevfat.py' |
1757 | --- bzrlib/transport/fakevfat.py 2009-03-23 14:59:43 +0000 |
1758 | +++ bzrlib/transport/fakevfat.py 2010-02-11 09:31:16 +0000 |
1759 | @@ -41,7 +41,7 @@ |
1760 | import re |
1761 | |
1762 | from bzrlib.errors import TransportNotPossible |
1763 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
1764 | +from bzrlib.transport import decorator |
1765 | |
1766 | |
1767 | # TODO: It might be nice if these hooks were available in a more general way |
1768 | @@ -52,7 +52,7 @@ |
1769 | # which are not implemented here fail by default? |
1770 | |
1771 | |
1772 | -class FakeVFATTransportDecorator(TransportDecorator): |
1773 | +class FakeVFATTransportDecorator(decorator.TransportDecorator): |
1774 | """A decorator that can convert any transport to be readonly. |
1775 | |
1776 | This is requested via the 'vfat+' prefix to get_transport(). |
1777 | @@ -99,17 +99,7 @@ |
1778 | return self._decorated.put_file(self._squash_name(relpath), f, mode) |
1779 | |
1780 | |
1781 | -class FakeVFATServer(DecoratorServer): |
1782 | - """A server that suggests connections through FakeVFATTransportDecorator |
1783 | - |
1784 | - For use in testing. |
1785 | - """ |
1786 | - |
1787 | - def get_decorator_class(self): |
1788 | - return FakeVFATTransportDecorator |
1789 | - |
1790 | - |
1791 | def get_test_permutations(): |
1792 | """Return the permutations to be used in testing.""" |
1793 | - return [(FakeVFATTransportDecorator, FakeVFATServer), |
1794 | - ] |
1795 | + from bzrlib.tests import test_server |
1796 | + return [(FakeVFATTransportDecorator, test_server.FakeVFATServer),] |
1797 | |
1798 | === modified file 'bzrlib/transport/local.py' |
1799 | --- bzrlib/transport/local.py 2010-01-07 03:03:01 +0000 |
1800 | +++ bzrlib/transport/local.py 2010-02-11 09:31:16 +0000 |
1801 | @@ -39,14 +39,14 @@ |
1802 | from bzrlib.transport import LateReadError |
1803 | """) |
1804 | |
1805 | -from bzrlib.transport import Transport, Server |
1806 | +from bzrlib import transport |
1807 | |
1808 | |
1809 | _append_flags = os.O_CREAT | os.O_APPEND | os.O_WRONLY | osutils.O_BINARY |
1810 | _put_non_atomic_flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | osutils.O_BINARY |
1811 | |
1812 | |
1813 | -class LocalTransport(Transport): |
1814 | +class LocalTransport(transport.Transport): |
1815 | """This is the transport agent for local filesystem access.""" |
1816 | |
1817 | def __init__(self, base): |
1818 | @@ -554,23 +554,7 @@ |
1819 | return EmulatedWin32LocalTransport(abspath) |
1820 | |
1821 | |
1822 | -class LocalURLServer(Server): |
1823 | - """A pretend server for local transports, using file:// urls. |
1824 | - |
1825 | - Of course no actual server is required to access the local filesystem, so |
1826 | - this just exists to tell the test code how to get to it. |
1827 | - """ |
1828 | - |
1829 | - def start_server(self): |
1830 | - pass |
1831 | - |
1832 | - def get_url(self): |
1833 | - """See Transport.Server.get_url.""" |
1834 | - return urlutils.local_path_to_url('') |
1835 | - |
1836 | - |
1837 | def get_test_permutations(): |
1838 | """Return the permutations to be used in testing.""" |
1839 | - return [ |
1840 | - (LocalTransport, LocalURLServer), |
1841 | - ] |
1842 | + from bzrlib.tests import test_server |
1843 | + return [(LocalTransport, test_server.LocalURLServer),] |
1844 | |
1845 | === modified file 'bzrlib/transport/log.py' |
1846 | --- bzrlib/transport/log.py 2010-02-04 16:06:36 +0000 |
1847 | +++ bzrlib/transport/log.py 2010-02-11 09:31:16 +0000 |
1848 | @@ -26,18 +26,10 @@ |
1849 | import types |
1850 | |
1851 | from bzrlib.trace import mutter |
1852 | -from bzrlib.transport.decorator import ( |
1853 | - TransportDecorator, |
1854 | - ) |
1855 | -from bzrlib.transport.trace import ( |
1856 | - DecoratorServer, |
1857 | - TransportTraceDecorator, |
1858 | - ) |
1859 | - |
1860 | - |
1861 | - |
1862 | - |
1863 | -class TransportLogDecorator(TransportDecorator): |
1864 | +from bzrlib.transport import decorator |
1865 | + |
1866 | + |
1867 | +class TransportLogDecorator(decorator.TransportDecorator): |
1868 | """Decorator for Transports that logs interesting operations to .bzr.log. |
1869 | |
1870 | In general we want to log things that usually take a network round trip |
1871 | @@ -156,13 +148,7 @@ |
1872 | return t |
1873 | |
1874 | |
1875 | -class LogDecoratorServer(DecoratorServer): |
1876 | - """Server for testing.""" |
1877 | - |
1878 | - def get_decorator_class(self): |
1879 | - return TransportLogDecorator |
1880 | - |
1881 | - |
1882 | def get_test_permutations(): |
1883 | """Return the permutations to be used in testing.""" |
1884 | - return [(TransportLogDecorator, LogDecoratorServer)] |
1885 | + from bzrlib.tests import test_server |
1886 | + return [(TransportLogDecorator, test_server.LogDecoratorServer)] |
1887 | |
1888 | === modified file 'bzrlib/transport/memory.py' |
1889 | --- bzrlib/transport/memory.py 2010-01-08 17:28:25 +0000 |
1890 | +++ bzrlib/transport/memory.py 2010-02-11 09:31:16 +0000 |
1891 | @@ -28,6 +28,7 @@ |
1892 | import warnings |
1893 | |
1894 | from bzrlib import ( |
1895 | + transport, |
1896 | urlutils, |
1897 | ) |
1898 | from bzrlib.errors import ( |
1899 | @@ -42,10 +43,6 @@ |
1900 | AppendBasedFileStream, |
1901 | _file_streams, |
1902 | LateReadError, |
1903 | - register_transport, |
1904 | - Server, |
1905 | - Transport, |
1906 | - unregister_transport, |
1907 | ) |
1908 | |
1909 | |
1910 | @@ -64,7 +61,7 @@ |
1911 | self.st_mode = S_IFDIR | perms |
1912 | |
1913 | |
1914 | -class MemoryTransport(Transport): |
1915 | +class MemoryTransport(transport.Transport): |
1916 | """This is an in memory file system for transient data storage.""" |
1917 | |
1918 | def __init__(self, url=""): |
1919 | @@ -303,7 +300,7 @@ |
1920 | self.transport = None |
1921 | |
1922 | |
1923 | -class MemoryServer(Server): |
1924 | +class MemoryServer(transport.Server): |
1925 | """Server for the MemoryTransport for testing with.""" |
1926 | |
1927 | def start_server(self): |
1928 | @@ -312,22 +309,26 @@ |
1929 | self._locks = {} |
1930 | self._scheme = "memory+%s:///" % id(self) |
1931 | def memory_factory(url): |
1932 | - result = MemoryTransport(url) |
1933 | + from bzrlib.transport import memory |
1934 | + result = memory.MemoryTransport(url) |
1935 | result._dirs = self._dirs |
1936 | result._files = self._files |
1937 | result._locks = self._locks |
1938 | return result |
1939 | self._memory_factory = memory_factory |
1940 | - register_transport(self._scheme, self._memory_factory) |
1941 | + transport.register_transport(self._scheme, self._memory_factory) |
1942 | |
1943 | def stop_server(self): |
1944 | # unregister this server |
1945 | - unregister_transport(self._scheme, self._memory_factory) |
1946 | + transport.unregister_transport(self._scheme, self._memory_factory) |
1947 | |
1948 | def get_url(self): |
1949 | """See bzrlib.transport.Server.get_url.""" |
1950 | return self._scheme |
1951 | |
1952 | + def get_bogus_url(self): |
1953 | + raise NotImplementedError |
1954 | + |
1955 | |
1956 | def get_test_permutations(): |
1957 | """Return the permutations to be used in testing.""" |
1958 | |
1959 | === modified file 'bzrlib/transport/nosmart.py' |
1960 | --- bzrlib/transport/nosmart.py 2009-03-23 14:59:43 +0000 |
1961 | +++ bzrlib/transport/nosmart.py 2010-02-11 09:31:16 +0000 |
1962 | @@ -22,10 +22,10 @@ |
1963 | """ |
1964 | |
1965 | from bzrlib import errors |
1966 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
1967 | - |
1968 | - |
1969 | -class NoSmartTransportDecorator(TransportDecorator): |
1970 | +from bzrlib.transport import decorator |
1971 | + |
1972 | + |
1973 | +class NoSmartTransportDecorator(decorator.TransportDecorator): |
1974 | """A decorator for transports that disables get_smart_medium.""" |
1975 | |
1976 | @classmethod |
1977 | @@ -36,14 +36,8 @@ |
1978 | raise errors.NoSmartMedium(self) |
1979 | |
1980 | |
1981 | -class NoSmartTransportServer(DecoratorServer): |
1982 | - """Server for the NoSmartTransportDecorator for testing with.""" |
1983 | - |
1984 | - def get_decorator_class(self): |
1985 | - return NoSmartTransportDecorator |
1986 | - |
1987 | - |
1988 | def get_test_permutations(): |
1989 | """Return the permutations to be used in testing.""" |
1990 | - return [(NoSmartTransportDecorator, NoSmartTransportServer)] |
1991 | + from bzrlib.tests import test_server |
1992 | + return [(NoSmartTransportDecorator, test_server.NoSmartTransportServer)] |
1993 | |
1994 | |
1995 | === modified file 'bzrlib/transport/pathfilter.py' |
1996 | --- bzrlib/transport/pathfilter.py 2010-01-07 03:03:01 +0000 |
1997 | +++ bzrlib/transport/pathfilter.py 2010-02-11 09:31:16 +0000 |
1998 | @@ -174,22 +174,7 @@ |
1999 | return self._call('stat', relpath) |
2000 | |
2001 | |
2002 | -class TestingPathFilteringServer(PathFilteringServer): |
2003 | - |
2004 | - def __init__(self): |
2005 | - """TestingChrootServer is not usable until start_server is called.""" |
2006 | - |
2007 | - def start_server(self, backing_server=None): |
2008 | - """Setup the Chroot on backing_server.""" |
2009 | - if backing_server is not None: |
2010 | - self.backing_transport = get_transport(backing_server.get_url()) |
2011 | - else: |
2012 | - self.backing_transport = get_transport('.') |
2013 | - self.backing_transport.clone('added-by-filter').ensure_base() |
2014 | - self.filter_func = lambda x: 'added-by-filter/' + x |
2015 | - PathFilteringServer.start_server(self) |
2016 | - |
2017 | - |
2018 | def get_test_permutations(): |
2019 | """Return the permutations to be used in testing.""" |
2020 | - return [(PathFilteringTransport, TestingPathFilteringServer)] |
2021 | + from bzrlib.tests import test_server |
2022 | + return [(PathFilteringTransport, test_server.TestingPathFilteringServer)] |
2023 | |
2024 | === modified file 'bzrlib/transport/readonly.py' |
2025 | --- bzrlib/transport/readonly.py 2009-03-24 01:53:42 +0000 |
2026 | +++ bzrlib/transport/readonly.py 2010-02-11 09:31:16 +0000 |
2027 | @@ -17,10 +17,10 @@ |
2028 | """Implementation of Transport that adapts another transport to be readonly.""" |
2029 | |
2030 | from bzrlib.errors import TransportNotPossible, NoSmartMedium |
2031 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
2032 | - |
2033 | - |
2034 | -class ReadonlyTransportDecorator(TransportDecorator): |
2035 | +from bzrlib.transport import decorator |
2036 | + |
2037 | + |
2038 | +class ReadonlyTransportDecorator(decorator.TransportDecorator): |
2039 | """A decorator that can convert any transport to be readonly. |
2040 | |
2041 | This is requested via the 'readonly+' prefix to get_transport(). |
2042 | @@ -78,15 +78,7 @@ |
2043 | raise NoSmartMedium(self) |
2044 | |
2045 | |
2046 | - |
2047 | -class ReadonlyServer(DecoratorServer): |
2048 | - """Server for the ReadonlyTransportDecorator for testing with.""" |
2049 | - |
2050 | - def get_decorator_class(self): |
2051 | - return ReadonlyTransportDecorator |
2052 | - |
2053 | - |
2054 | def get_test_permutations(): |
2055 | """Return the permutations to be used in testing.""" |
2056 | - return [(ReadonlyTransportDecorator, ReadonlyServer), |
2057 | - ] |
2058 | + from bzrlib.tests import test_server |
2059 | + return [(ReadonlyTransportDecorator, test_server.ReadonlyServer),] |
2060 | |
2061 | === modified file 'bzrlib/transport/remote.py' |
2062 | --- bzrlib/transport/remote.py 2009-03-24 01:53:42 +0000 |
2063 | +++ bzrlib/transport/remote.py 2010-02-11 09:31:16 +0000 |
2064 | @@ -601,5 +601,5 @@ |
2065 | """Return (transport, server) permutations for testing.""" |
2066 | ### We may need a little more test framework support to construct an |
2067 | ### appropriate RemoteTransport in the future. |
2068 | - from bzrlib.smart import server |
2069 | - return [(RemoteTCPTransport, server.SmartTCPServer_for_testing)] |
2070 | + from bzrlib.tests import test_server |
2071 | + return [(RemoteTCPTransport, test_server.SmartTCPServer_for_testing)] |
2072 | |
2073 | === modified file 'bzrlib/transport/trace.py' |
2074 | --- bzrlib/transport/trace.py 2009-07-02 03:48:56 +0000 |
2075 | +++ bzrlib/transport/trace.py 2010-02-11 09:31:16 +0000 |
2076 | @@ -20,10 +20,10 @@ |
2077 | and then delegates it. |
2078 | """ |
2079 | |
2080 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
2081 | - |
2082 | - |
2083 | -class TransportTraceDecorator(TransportDecorator): |
2084 | +from bzrlib.transport import decorator |
2085 | + |
2086 | + |
2087 | +class TransportTraceDecorator(decorator.TransportDecorator): |
2088 | """A tracing decorator for Transports. |
2089 | |
2090 | Calls that potentially perform IO are logged to self._activity. The |
2091 | @@ -43,7 +43,7 @@ |
2092 | |
2093 | _decorated is a private parameter for cloning. |
2094 | """ |
2095 | - TransportDecorator.__init__(self, url, _decorated) |
2096 | + super(TransportTraceDecorator, self).__init__(url, _decorated) |
2097 | if _from_transport is None: |
2098 | # newly created |
2099 | self._activity = [] |
2100 | @@ -169,13 +169,7 @@ |
2101 | self._activity.append(operation_tuple) |
2102 | |
2103 | |
2104 | -class TraceServer(DecoratorServer): |
2105 | - """Server for the TransportTraceDecorator for testing with.""" |
2106 | - |
2107 | - def get_decorator_class(self): |
2108 | - return TransportTraceDecorator |
2109 | - |
2110 | - |
2111 | def get_test_permutations(): |
2112 | """Return the permutations to be used in testing.""" |
2113 | - return [(TransportTraceDecorator, TraceServer)] |
2114 | + from bzrlib.tests import test_server |
2115 | + return [(TransportTraceDecorator, test_server.TraceServer)] |
2116 | |
2117 | === modified file 'bzrlib/transport/unlistable.py' |
2118 | --- bzrlib/transport/unlistable.py 2009-03-23 14:59:43 +0000 |
2119 | +++ bzrlib/transport/unlistable.py 2010-02-11 09:31:16 +0000 |
2120 | @@ -18,10 +18,10 @@ |
2121 | |
2122 | import bzrlib.errors as errors |
2123 | from bzrlib.transport import Transport |
2124 | -from bzrlib.transport.decorator import TransportDecorator, DecoratorServer |
2125 | - |
2126 | - |
2127 | -class UnlistableTransportDecorator(TransportDecorator): |
2128 | +from bzrlib.transport import decorator |
2129 | + |
2130 | + |
2131 | +class UnlistableTransportDecorator(decorator.TransportDecorator): |
2132 | """A transport that disables file listing for testing.""" |
2133 | |
2134 | @classmethod |
2135 | @@ -39,14 +39,7 @@ |
2136 | Transport.list_dir(self, relpath) |
2137 | |
2138 | |
2139 | -class UnlistableServer(DecoratorServer): |
2140 | - """Server for the UnlistableTransportDecorator for testing with.""" |
2141 | - |
2142 | - def get_decorator_class(self): |
2143 | - return UnlistableTransportDecorator |
2144 | - |
2145 | - |
2146 | def get_test_permutations(): |
2147 | """Return the permutations to be used in testing.""" |
2148 | - return [(UnlistableTransportDecorator, UnlistableServer), |
2149 | - ] |
2150 | + from bzrlib.tests import test_server |
2151 | + return [(UnlistableTransportDecorator, test_server.UnlistableServer),] |
This patch moves test servers out of the bzrlib.transport hierarchy test.test_ server and all related fallouts.
to bzrlib.
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...