/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Martin Pool
  • Date: 2008-05-08 04:33:38 UTC
  • mfrom: (3414 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080508043338-ru3vflx8z641a76k
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
class FakeControlFiles(object):
160
160
 
161
161
    def __init__(self, user_id=None):
162
 
        self.email = user_id
163
162
        self.files = {}
 
163
        if user_id:
 
164
            self.files['email'] = user_id
164
165
        self._transport = self
165
166
 
166
167
    def get_utf8(self, filename):
167
 
        if filename != 'email':
168
 
            raise NotImplementedError
169
 
        if self.email is not None:
170
 
            return StringIO(self.email)
171
 
        raise errors.NoSuchFile(filename)
 
168
        # from LockableFiles
 
169
        raise AssertionError("get_utf8 should no longer be used")
172
170
 
173
171
    def get(self, filename):
 
172
        # from Transport
174
173
        try:
175
174
            return StringIO(self.files[filename])
176
175
        except KeyError:
177
176
            raise errors.NoSuchFile(filename)
178
177
 
 
178
    def get_bytes(self, filename):
 
179
        # from Transport
 
180
        try:
 
181
            return self.files[filename]
 
182
        except KeyError:
 
183
            raise errors.NoSuchFile(filename)
 
184
 
179
185
    def put(self, filename, fileobj):
180
186
        self.files[filename] = fileobj.read()
181
187
 
965
971
        my_config = config.BranchConfig(branch)
966
972
        self.assertEqual("Robert Collins <robertc@example.net>",
967
973
                         my_config.username())
968
 
        branch.control_files.email = "John"
 
974
        my_config.branch.control_files.files['email'] = "John"
969
975
        my_config.set_user_option('email',
970
976
                                  "Robert Collins <robertc@example.org>")
971
977
        self.assertEqual("John", my_config.username())
972
 
        branch.control_files.email = None
 
978
        del my_config.branch.control_files.files['email']
973
979
        self.assertEqual("Robert Collins <robertc@example.org>",
974
980
                         my_config.username())
975
981
 
976
982
    def test_not_set_in_branch(self):
977
983
        my_config = self.get_branch_config(sample_config_text)
978
 
        my_config.branch.control_files.email = None
979
984
        self.assertEqual(u"Erik B\u00e5gfors <erik@bagfors.nu>",
980
985
                         my_config._get_user_id())
981
 
        my_config.branch.control_files.email = "John"
 
986
        my_config.branch.control_files.files['email'] = "John"
982
987
        self.assertEqual("John", my_config._get_user_id())
983
988
 
984
989
    def test_BZR_EMAIL_OVERRIDES(self):