~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
6379.6.7 by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear.
17
"""Transport implementation that disables listing to simulate HTTP cheaply."""
18
6379.6.3 by Jelmer Vernooij
Use absolute_import.
19
from __future__ import absolute_import
20
2617.4.1 by Robert Collins
Add a new transport decorator unlistable+ for testing.
21
from bzrlib.transport import Transport
5017.3.13 by Vincent Ladeuil
Move UnlistableServer to bzrlib.tests.test_server
22
from bzrlib.transport import decorator
23
24
25
class UnlistableTransportDecorator(decorator.TransportDecorator):
2617.4.1 by Robert Collins
Add a new transport decorator unlistable+ for testing.
26
    """A transport that disables file listing for testing."""
27
28
    @classmethod
29
    def _get_url_prefix(self):
30
        """Unlistable transports are identified by 'unlistable+'"""
31
        return 'unlistable+'
32
33
    def iter_files_recursive(self):
34
        Transport.iter_files_recursive(self)
35
36
    def listable(self):
37
        return False
38
39
    def list_dir(self, relpath):
40
        Transport.list_dir(self, relpath)
41
42
43
def get_test_permutations():
44
    """Return the permutations to be used in testing."""
5017.3.13 by Vincent Ladeuil
Move UnlistableServer to bzrlib.tests.test_server
45
    from bzrlib.tests import test_server
46
    return [(UnlistableTransportDecorator, test_server.UnlistableServer),]