~bzr-pqm/bzr/bzr.dev

2617.4.1 by Robert Collins
Add a new transport decorator unlistable+ for testing.
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2617.4.1 by Robert Collins
Add a new transport decorator unlistable+ for testing.
16
17
"""Transport implementation that disables listing to simulate HTTP cheaply."""
18
19
import bzrlib.errors as errors
20
from bzrlib.transport import Transport
5017.3.13 by Vincent Ladeuil
Move UnlistableServer to bzrlib.tests.test_server
21
from bzrlib.transport import decorator
22
23
24
class UnlistableTransportDecorator(decorator.TransportDecorator):
2617.4.1 by Robert Collins
Add a new transport decorator unlistable+ for testing.
25
    """A transport that disables file listing for testing."""
26
27
    @classmethod
28
    def _get_url_prefix(self):
29
        """Unlistable transports are identified by 'unlistable+'"""
30
        return 'unlistable+'
31
32
    def iter_files_recursive(self):
33
        Transport.iter_files_recursive(self)
34
35
    def listable(self):
36
        return False
37
38
    def list_dir(self, relpath):
39
        Transport.list_dir(self, relpath)
40
41
42
def get_test_permutations():
43
    """Return the permutations to be used in testing."""
5017.3.13 by Vincent Ladeuil
Move UnlistableServer to bzrlib.tests.test_server
44
    from bzrlib.tests import test_server
45
    return [(UnlistableTransportDecorator, test_server.UnlistableServer),]