~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

  • Committer: Aaron Bentley
  • Date: 2008-06-26 05:10:31 UTC
  • mto: This revision was merged to the branch mainline in revision 3514.
  • Revision ID: aaron@aaronbentley.com-20080626051031-ylyzlwa3t41dd3it
Add support for branch-associated locations

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
20
from bzrlib.directory_service import DirectoryServiceRegistry, directories
20
 
from bzrlib.tests import TestCase
 
21
from bzrlib.tests import TestCase, TestCaseWithTransport
21
22
from bzrlib.transport import get_transport
22
23
 
23
24
 
49
50
        directories.register('foo:', FooService, 'Map foo URLs to http urls')
50
51
        self.addCleanup(lambda: directories.remove('foo:'))
51
52
        self.assertEqual('file:///foobar/', get_transport('foo:bar').base)
 
53
 
 
54
 
 
55
class TestAliasDirectory(TestCaseWithTransport):
 
56
 
 
57
    def test_lookup_parent(self):
 
58
        branch = self.make_branch('.')
 
59
        branch.set_parent('http://a')
 
60
        self.assertEqual('http://a', directories.dereference(':parent'))
 
61
 
 
62
    def test_lookup_submit(self):
 
63
        branch = self.make_branch('.')
 
64
        branch.set_submit_branch('http://b')
 
65
        self.assertEqual('http://b', directories.dereference(':submit'))
 
66
 
 
67
    def test_lookup_public(self):
 
68
        branch = self.make_branch('.')
 
69
        branch.set_public_branch('http://c')
 
70
        self.assertEqual('http://c', directories.dereference(':public'))
 
71
 
 
72
    def test_lookup_bound(self):
 
73
        branch = self.make_branch('.')
 
74
        branch.set_bound_location('http://d')
 
75
        self.assertEqual('http://d', directories.dereference(':bound'))
 
76
 
 
77
    def test_lookup_badname(self):
 
78
        branch = self.make_branch('.')
 
79
        e = self.assertRaises(errors.InvalidLocationAlias,
 
80
                              directories.dereference, ':booga')
 
81
        self.assertEqual('":booga" is not a valid location alias.',
 
82
                         str(e))
 
83
 
 
84
    def test_lookup_badvalue(self):
 
85
        branch = self.make_branch('.')
 
86
        e = self.assertRaises(errors.UnsetLocationAlias,
 
87
                              directories.dereference, ':parent')
 
88
        self.assertEqual('No parent location assigned.', str(e))