~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

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
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
57
        self.addCleanup(lambda: directories.remove('foo:'))
53
 
        self.assertEqual('file:///foobar/', get_transport('foo:bar').base)
 
58
        self.assertEqual(FooService.base + 'bar/',
 
59
                         get_transport('foo:bar').base)
54
60
 
55
61
 
56
62
class TestAliasDirectory(TestCaseWithTransport):