/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

  • Committer: Andrew Bennetts
  • Date: 2010-04-13 04:33:55 UTC
  • mfrom: (5147 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5149.
  • Revision ID: andrew.bennetts@canonical.com-20100413043355-lg3id0uwtju0k3zs
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Test directory service implementation"""
18
18
 
19
 
from bzrlib import errors
 
19
from bzrlib import (
 
20
    errors,
 
21
    urlutils,
 
22
    )
20
23
from bzrlib.directory_service import DirectoryServiceRegistry, directories
21
24
from bzrlib.tests import TestCase, TestCaseWithTransport
22
25
from bzrlib.transport import get_transport
23
 
from bzrlib import urlutils
24
26
 
25
27
 
26
28
class FooService(object):
27
29
    """A directory service that maps the name to a FILE url"""
28
30
 
 
31
    # eg 'file:///foo' on Linux, or 'file:///C:/foo' on Windows
 
32
    base = urlutils.local_path_to_url('/foo')
 
33
 
29
34
    def look_up(self, name, url):
30
 
        return 'file:///foo' + name
 
35
        return self.base + name
31
36
 
32
37
 
33
38
class TestDirectoryLookup(TestCase):
43
48
        self.assertEqual('bar', suffix)
44
49
 
45
50
    def test_dereference(self):
46
 
        self.assertEqual('file:///foobar',
 
51
        self.assertEqual(FooService.base + 'bar',
47
52
                         self.registry.dereference('foo:bar'))
48
53
        self.assertEqual('baz:qux', self.registry.dereference('baz:qux'))
49
54
 
50
55
    def test_get_transport(self):
51
56
        directories.register('foo:', FooService, 'Map foo URLs to http urls')
52
 
        self.addCleanup(lambda: directories.remove('foo:'))
53
 
        self.assertEqual('file:///foobar/', get_transport('foo:bar').base)
 
57
        self.addCleanup(directories.remove, 'foo:')
 
58
        self.assertEqual(FooService.base + 'bar/',
 
59
                         get_transport('foo:bar').base)
54
60
 
55
61
 
56
62
class TestAliasDirectory(TestCaseWithTransport):