~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_directory_service.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2012, 2016 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
42
42
class TestDirectoryLookup(TestCase):
43
43
 
44
44
    def setUp(self):
45
 
        super(TestDirectoryLookup, self).setUp()
 
45
        TestCase.setUp(self)
46
46
        self.registry = DirectoryServiceRegistry()
47
47
        self.registry.register('foo:', FooService, 'Map foo URLs to http urls')
48
48
 
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.assertEqual(value, directories.dereference(alias))
75
 
 
76
68
    def test_lookup_parent(self):
77
 
        self.assertAliasFromBranch(self.branch.set_parent, 'http://a',
78
 
                                  ':parent')
 
69
        branch = self.make_branch('.')
 
70
        branch.set_parent('http://a')
 
71
        self.assertEqual('http://a', directories.dereference(':parent'))
79
72
 
80
73
    def test_lookup_submit(self):
81
 
        self.assertAliasFromBranch(self.branch.set_submit_branch, 'http://b',
82
 
                                   ':submit')
 
74
        branch = self.make_branch('.')
 
75
        branch.set_submit_branch('http://b')
 
76
        self.assertEqual('http://b', directories.dereference(':submit'))
83
77
 
84
78
    def test_lookup_public(self):
85
 
        self.assertAliasFromBranch(self.branch.set_public_branch, 'http://c',
86
 
                                   ':public')
 
79
        branch = self.make_branch('.')
 
80
        branch.set_public_branch('http://c')
 
81
        self.assertEqual('http://c', directories.dereference(':public'))
87
82
 
88
83
    def test_lookup_bound(self):
89
 
        self.assertAliasFromBranch(self.branch.set_bound_location, 'http://d',
90
 
                                   ':bound')
 
84
        branch = self.make_branch('.')
 
85
        branch.set_bound_location('http://d')
 
86
        self.assertEqual('http://d', directories.dereference(':bound'))
91
87
 
92
88
    def test_lookup_push(self):
93
 
        self.assertAliasFromBranch(self.branch.set_push_location, 'http://e',
94
 
                                   ':push')
 
89
        branch = self.make_branch('.')
 
90
        branch.set_push_location('http://e')
 
91
        self.assertEqual('http://e', directories.dereference(':push'))
95
92
 
96
93
    def test_lookup_this(self):
97
 
        self.assertEqual(self.branch.base, directories.dereference(':this'))
 
94
        branch = self.make_branch('.')
 
95
        self.assertEqual(branch.base, directories.dereference(':this'))
98
96
 
99
97
    def test_extra_path(self):
100
 
        self.assertEqual(urlutils.join(self.branch.base, 'arg'),
 
98
        branch = self.make_branch('.')
 
99
        self.assertEqual(urlutils.join(branch.base, 'arg'),
101
100
                         directories.dereference(':this/arg'))
102
101
 
103
102
    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('.')
110
111
        e = self.assertRaises(errors.UnsetLocationAlias,
111
112
                              directories.dereference, ':parent')
112
113
        self.assertEqual('No parent location assigned.', str(e))
113
114
 
114
115
    def test_register_location_alias(self):
 
116
        branch = self.make_branch('.')
115
117
        self.addCleanup(AliasDirectory.branch_aliases.remove, "booga")
116
118
        AliasDirectory.branch_aliases.register("booga",
117
119
            lambda b: "UHH?", help="Nobody knows")
118
 
        self.assertEqual("UHH?", directories.dereference(":booga"))
119
 
 
120
 
 
121
 
class TestColocatedDirectory(TestCaseWithTransport):
122
 
 
123
 
    def test_lookup_non_default(self):
124
 
        default = self.make_branch('.')
125
 
        non_default = default.bzrdir.create_branch(name='nondefault')
126
 
        self.assertEqual(non_default.base, directories.dereference('co:nondefault'))
127
 
 
128
 
    def test_lookup_default(self):
129
 
        default = self.make_branch('.')
130
 
        non_default = default.bzrdir.create_branch(name='nondefault')
131
 
        self.assertEqual(urlutils.join_segment_parameters(default.bzrdir.user_url,
132
 
            {"branch": ""}), directories.dereference('co:'))
133
 
 
134
 
    def test_no_such_branch(self):
135
 
        # No error is raised in this case, that is up to the code that actually
136
 
        # opens the branch.
137
 
        default = self.make_branch('.')
138
 
        self.assertEqual(urlutils.join_segment_parameters(default.bzrdir.user_url,
139
 
            {"branch": "foo"}), directories.dereference('co:foo'))
 
120
        self.assertEquals("UHH?", directories.dereference(":booga"))