~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-16 22:42:54 UTC
  • mfrom: (4797.3.21 2.1.0b4-win32-accepted)
  • Revision ID: pqm@pqm.ubuntu.com-20091116224254-fgspnq9xz29z662j
(jam) Lots of win32 test-suite fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):