~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008-2012 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
65
65
 
66
66
class TestAliasDirectory(TestCaseWithTransport):
67
67
 
 
68
    def setUp(self):
 
69
        super(TestAliasDirectory, self).setUp()
 
70
        self.branch = self.make_branch('.')
 
71
 
 
72
    def assertAliasFromBranch(self, setter, value, alias):
 
73
        setter(value)
 
74
        self.assertEquals(value, directories.dereference(alias))
 
75
 
68
76
    def test_lookup_parent(self):
69
 
        branch = self.make_branch('.')
70
 
        branch.set_parent('http://a')
71
 
        self.assertEqual('http://a', directories.dereference(':parent'))
 
77
        self.assertAliasFromBranch(self.branch.set_parent, 'http://a',
 
78
                                  ':parent')
72
79
 
73
80
    def test_lookup_submit(self):
74
 
        branch = self.make_branch('.')
75
 
        branch.set_submit_branch('http://b')
76
 
        self.assertEqual('http://b', directories.dereference(':submit'))
 
81
        self.assertAliasFromBranch(self.branch.set_submit_branch, 'http://b',
 
82
                                   ':submit')
77
83
 
78
84
    def test_lookup_public(self):
79
 
        branch = self.make_branch('.')
80
 
        branch.set_public_branch('http://c')
81
 
        self.assertEqual('http://c', directories.dereference(':public'))
 
85
        self.assertAliasFromBranch(self.branch.set_public_branch, 'http://c',
 
86
                                   ':public')
82
87
 
83
88
    def test_lookup_bound(self):
84
 
        branch = self.make_branch('.')
85
 
        branch.set_bound_location('http://d')
86
 
        self.assertEqual('http://d', directories.dereference(':bound'))
 
89
        self.assertAliasFromBranch(self.branch.set_bound_location, 'http://d',
 
90
                                   ':bound')
87
91
 
88
92
    def test_lookup_push(self):
89
 
        branch = self.make_branch('.')
90
 
        branch.set_push_location('http://e')
91
 
        self.assertEqual('http://e', directories.dereference(':push'))
 
93
        self.assertAliasFromBranch(self.branch.set_push_location, 'http://e',
 
94
                                   ':push')
92
95
 
93
96
    def test_lookup_this(self):
94
 
        branch = self.make_branch('.')
95
 
        self.assertEqual(branch.base, directories.dereference(':this'))
 
97
        self.assertEqual(self.branch.base, directories.dereference(':this'))
96
98
 
97
99
    def test_extra_path(self):
98
 
        branch = self.make_branch('.')
99
 
        self.assertEqual(urlutils.join(branch.base, 'arg'),
 
100
        self.assertEqual(urlutils.join(self.branch.base, 'arg'),
100
101
                         directories.dereference(':this/arg'))
101
102
 
102
103
    def test_lookup_badname(self):
103
 
        branch = self.make_branch('.')
104
104
        e = self.assertRaises(errors.InvalidLocationAlias,
105
105
                              directories.dereference, ':booga')
106
106
        self.assertEqual('":booga" is not a valid location alias.',
107
107
                         str(e))
108
108
 
109
109
    def test_lookup_badvalue(self):
110
 
        branch = self.make_branch('.')
111
110
        e = self.assertRaises(errors.UnsetLocationAlias,
112
111
                              directories.dereference, ':parent')
113
112
        self.assertEqual('No parent location assigned.', str(e))
114
113
 
115
114
    def test_register_location_alias(self):
116
 
        branch = self.make_branch('.')
117
115
        self.addCleanup(AliasDirectory.branch_aliases.remove, "booga")
118
116
        AliasDirectory.branch_aliases.register("booga",
119
117
            lambda b: "UHH?", help="Nobody knows")