~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-16 13:39:39 UTC
  • mto: (5923.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5925.
  • Revision ID: jelmer@samba.org-20110516133939-8u1pc9utas3uw1lt
Require a unicode prompt to be passed into all methods that prompt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
test_store_builder_registry.register(
86
86
    'branch', lambda test: config.BranchStore(test.branch))
87
87
 
88
 
# FIXME: Same remark as above for the following registry -- vila 20110503
89
 
test_stack_builder_registry = registry.Registry()
90
 
test_stack_builder_registry.register(
91
 
    'bazaar', lambda test: config.GlobalStack())
92
 
test_stack_builder_registry.register(
93
 
    'location', lambda test: config.LocationStack('.'))
94
 
test_stack_builder_registry.register(
95
 
    'branch', lambda test: config.BranchStack(test.branch))
96
88
 
97
89
 
98
90
sample_long_alias="log -r-15..-1 --line"
2185
2177
        self.assertEquals(['baz', 'bar/baz'],
2186
2178
                          [section.extra_path for section in sections])
2187
2179
 
2188
 
    def test_appendpath_in_no_name_section(self):
2189
 
        # It's a bit weird to allow appendpath in a no-name section, but
2190
 
        # someone may found a use for it
2191
 
        store = self.get_store('foo.conf')
2192
 
        store._load_from_string('''
2193
 
foo=bar
2194
 
foo:policy = appendpath
2195
 
''')
2196
 
        matcher = config.LocationMatcher(store, 'dir/subdir')
2197
 
        sections = list(matcher.get_sections())
2198
 
        self.assertLength(1, sections)
2199
 
        self.assertEquals('bar/dir/subdir', sections[0].get('foo'))
2200
 
 
2201
 
    def test_file_urls_are_normalized(self):
2202
 
        store = self.get_store('foo.conf')
2203
 
        matcher = config.LocationMatcher(store, 'file:///dir/subdir')
2204
 
        self.assertEquals('/dir/subdir', matcher.location)
2205
2180
 
2206
2181
 
2207
2182
class TestStackGet(tests.TestCase):
2240
2215
        self.assertRaises(TypeError, conf_stack.get, 'foo')
2241
2216
 
2242
2217
 
2243
 
class TestStackWithTransport(tests.TestCaseWithTransport):
2244
 
 
2245
 
    def setUp(self):
2246
 
        super(TestStackWithTransport, self).setUp()
2247
 
        # FIXME: A more elaborate builder for the stack would avoid building a
2248
 
        # branch even for tests that don't need it.
2249
 
        self.branch = self.make_branch('branch')
2250
 
 
2251
 
 
2252
 
class TestStackSet(TestStackWithTransport):
2253
 
 
2254
 
    scenarios = [(key, {'get_stack': builder})
2255
 
                 for key, builder in test_stack_builder_registry.iteritems()]
 
2218
class TestStackSet(tests.TestCaseWithTransport):
 
2219
 
 
2220
    # FIXME: This should be parametrized for all known Stack or dedicated
 
2221
    # paramerized tests created to avoid bloating -- vila 2011-04-05
2256
2222
 
2257
2223
    def test_simple_set(self):
2258
 
        conf = self.get_stack(self)
2259
 
        conf.store._load_from_string('foo=bar')
 
2224
        store = config.IniFileStore(self.get_transport(), 'test.conf')
 
2225
        store._load_from_string('foo=bar')
 
2226
        conf = config.Stack([store.get_sections], store)
2260
2227
        self.assertEquals('bar', conf.get('foo'))
2261
2228
        conf.set('foo', 'baz')
2262
2229
        # Did we get it back ?
2263
2230
        self.assertEquals('baz', conf.get('foo'))
2264
2231
 
2265
2232
    def test_set_creates_a_new_section(self):
2266
 
        conf = self.get_stack(self)
 
2233
        store = config.IniFileStore(self.get_transport(), 'test.conf')
 
2234
        conf = config.Stack([store.get_sections], store)
2267
2235
        conf.set('foo', 'baz')
2268
2236
        self.assertEquals, 'baz', conf.get('foo')
2269
2237
 
2270
2238
 
2271
 
class TestStackRemove(TestStackWithTransport):
 
2239
class TestStackRemove(tests.TestCaseWithTransport):
2272
2240
 
2273
 
    scenarios = [(key, {'get_stack': builder})
2274
 
                 for key, builder in test_stack_builder_registry.iteritems()]
 
2241
    # FIXME: This should be parametrized for all known Stack or dedicated
 
2242
    # paramerized tests created to avoid bloating -- vila 2011-04-06
2275
2243
 
2276
2244
    def test_remove_existing(self):
2277
 
        conf = self.get_stack(self)
2278
 
        conf.store._load_from_string('foo=bar')
 
2245
        store = config.IniFileStore(self.get_transport(), 'test.conf')
 
2246
        store._load_from_string('foo=bar')
 
2247
        conf = config.Stack([store.get_sections], store)
2279
2248
        self.assertEquals('bar', conf.get('foo'))
2280
2249
        conf.remove('foo')
2281
2250
        # Did we get it back ?
2282
2251
        self.assertEquals(None, conf.get('foo'))
2283
2252
 
2284
2253
    def test_remove_unknown(self):
2285
 
        conf = self.get_stack(self)
 
2254
        store = config.IniFileStore(self.get_transport(), 'test.conf')
 
2255
        conf = config.Stack([store.get_sections], store)
2286
2256
        self.assertRaises(KeyError, conf.remove, 'I_do_not_exist')
2287
2257
 
2288
2258
 
2289
 
class TestConcreteStacks(TestStackWithTransport):
2290
 
 
2291
 
    scenarios = [(key, {'get_stack': builder})
2292
 
                 for key, builder in test_stack_builder_registry.iteritems()]
2293
 
 
2294
 
    def test_build_stack(self):
2295
 
        stack = self.get_stack(self)
2296
 
 
2297
 
 
2298
2259
class TestConfigGetOptions(tests.TestCaseWithTransport, TestOptionsMixin):
2299
2260
 
2300
2261
    def setUp(self):