~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testconfig.py

[merge] robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
class InstrumentedConfigObj(object):
74
74
    """A config obj look-enough-alike to record calls made to it."""
75
75
 
 
76
    def __contains__(self, thing):
 
77
        self._calls.append(('__contains__', thing))
 
78
        return False
 
79
 
 
80
    def __getitem__(self, key):
 
81
        self._calls.append(('__getitem__', key))
 
82
        return self
 
83
 
76
84
    def __init__(self, input):
77
85
        self._calls = [('__init__', input)]
78
86
 
 
87
    def __setitem__(self, key, value):
 
88
        self._calls.append(('__setitem__', key, value))
 
89
 
 
90
    def write(self):
 
91
        self._calls.append(('write',))
 
92
 
79
93
 
80
94
class FakeBranch(object):
81
95
 
458
472
        self.assertEqual('bzrlib.selftest.testconfig.post_commit',
459
473
                         self.my_config.post_commit())
460
474
 
 
475
    def test_set_user_setting_sets_and_saves(self):
 
476
        # TODO RBC 20051029 test hat mkdir ~/.bazaar is called ..
 
477
        self.get_location_config('/a/c')
 
478
        record = InstrumentedConfigObj("foo")
 
479
        self.my_config._parser = record
 
480
        self.my_config.set_user_option('foo', 'bar')
 
481
        self.assertEqual([('__contains__', '/a/c'),
 
482
                          ('__contains__', '/a/c/'),
 
483
                          ('__setitem__', '/a/c', {}),
 
484
                          ('__getitem__', '/a/c'),
 
485
                          ('__setitem__', 'foo', 'bar'),
 
486
                          ('write',)],
 
487
                         record._calls[1:])
 
488
 
461
489
 
462
490
class TestBranchConfigItems(TestCase):
463
491