~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-09-07 08:23:49 UTC
  • mto: (6123.1.13 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6124.
  • Revision ID: v.ladeuil+lp@free.fr-20110907082349-1ly8p12duy1exzn3
Provide config.IdMatcher for config files defining secion names as unique ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
2624
2624
    scenarios = [(key, {'get_store': builder}) for key, builder
2625
2625
                 in config.test_store_builder_registry.iteritems()]
2626
2626
 
2627
 
    def setUp(self):
2628
 
        super(TestReadonlyStore, self).setUp()
2629
 
 
2630
2627
    def test_building_delays_load(self):
2631
2628
        store = self.get_store(self)
2632
2629
        self.assertEquals(False, store.is_loaded())
3061
3058
    # FIXME: It may be worth looking into removing the lock dir when it's not
3062
3059
    # needed anymore and look at possible fallouts for concurrent lockers. This
3063
3060
    # will matter if/when we use config files outside of bazaar directories
3064
 
    # (.bazaar or .bzr) -- vila 20110-04-11
 
3061
    # (.bazaar or .bzr) -- vila 20110-04-111
3065
3062
 
3066
3063
 
3067
3064
class TestSectionMatcher(TestStore):
3068
3065
 
3069
 
    scenarios = [('location', {'matcher': config.LocationMatcher})]
 
3066
    scenarios = [('location', {'matcher': config.LocationMatcher}),
 
3067
                 ('id', {'matcher': config.IdMatcher}),]
3070
3068
 
3071
3069
    def get_store(self, file_name):
3072
3070
        return config.IniFileStore(self.get_readonly_transport(), file_name)
3181
3179
        self.assertEquals(expected_location, matcher.location)
3182
3180
 
3183
3181
 
 
3182
class TestIdMatcher(TestStore):
 
3183
 
 
3184
    def setUp(self):
 
3185
        super(TestIdMatcher, self).setUp()
 
3186
        self.store = config.IniFileStore(self.get_readonly_transport(),
 
3187
                                         'foo.conf')
 
3188
        self.store._load_from_string('''
 
3189
[foo]
 
3190
option=foo
 
3191
[foo/baz]
 
3192
option=foo/baz
 
3193
[bar]
 
3194
option=bar
 
3195
''')
 
3196
 
 
3197
    def test_matching(self):
 
3198
        matcher = config.IdMatcher(self.store, 'foo')
 
3199
        sections = list(matcher.get_sections())
 
3200
        self.assertLength(1, sections)
 
3201
        self.assertSectionContent(('foo', {'option': 'foo'}), sections[0])
 
3202
 
 
3203
    def test_not_matching(self):
 
3204
        matcher = config.IdMatcher(self.store, 'baz')
 
3205
        sections = list(matcher.get_sections())
 
3206
        self.assertLength(0, sections)
 
3207
 
 
3208
 
3184
3209
class TestStackGet(tests.TestCase):
3185
3210
 
3186
3211
    # FIXME: This should be parametrized for all known Stack or dedicated