~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testconfig.py

- new commit --strict option

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
                        "# test trailing / matching with no children\n"
58
58
                        "[/a/]\n"
59
59
                        "check_signatures=check-available\n"
60
 
                        "gpg_signing_command=false\n"
61
60
                        "# test trailing / matching\n"
62
61
                        "[/a/*]\n"
63
62
                        "#subdirs will match but not the parent\n"
144
143
                         my_config.signature_checking())
145
144
        self.assertEqual(['_get_signature_checking'], my_config._calls)
146
145
 
147
 
    def test_gpg_signing_command_default(self):
148
 
        my_config = config.Config()
149
 
        self.assertEqual('gpg', my_config.gpg_signing_command())
150
 
 
151
146
 
152
147
class TestConfigPath(TestCase):
153
148
 
158
153
 
159
154
    def tearDown(self):
160
155
        os.environ['HOME'] = self.oldenv
161
 
        super(TestConfigPath, self).tearDown()
162
156
    
163
157
    def test_config_dir(self):
164
158
        self.assertEqual(config.config_dir(), '/home/bogus/.bazaar')
190
184
        self.failUnless(my_config._get_parser() is parser)
191
185
 
192
186
 
 
187
 
193
188
class TestGetConfig(TestCase):
194
189
 
195
190
    def test_constructs(self):
223
218
        self.failUnless(location_config is my_config._get_location_config())
224
219
 
225
220
 
226
 
class TestGlobalConfigItems(TestCase):
 
221
class TestConfigItems(TestCase):
 
222
 
 
223
    def setUp(self):
 
224
        super(TestConfigItems, self).setUp()
 
225
        self.bzr_email = os.environ.get('BZREMAIL')
 
226
        if self.bzr_email is not None:
 
227
            del os.environ['BZREMAIL']
 
228
        self.email = os.environ.get('EMAIL')
 
229
        if self.email is not None:
 
230
            del os.environ['EMAIL']
 
231
        self.oldenv = os.environ.get('HOME', None)
 
232
        os.environ['HOME'] = os.getcwd()
 
233
 
 
234
    def tearDown(self):
 
235
        os.environ['HOME'] = self.oldenv
 
236
        if os.environ.get('BZREMAIL') is not None:
 
237
            del os.environ['BZREMAIL']
 
238
        if self.bzr_email is not None:
 
239
            os.environ['BZREMAIL'] = self.bzr_email
 
240
        if self.email is not None:
 
241
            os.environ['EMAIL'] = self.email
 
242
        super(TestConfigItems, self).tearDown()
 
243
 
 
244
 
 
245
class TestGlobalConfigItems(TestConfigItems):
227
246
 
228
247
    def test_user_id(self):
229
248
        config_file = StringIO(sample_config_text)
268
287
                         my_config.signature_checking())
269
288
        self.assertEqual(False, my_config.signature_needed())
270
289
 
271
 
    def test_gpg_signing_command(self):
272
 
        config_file = StringIO(sample_config_text)
273
 
        my_config = config.GlobalConfig()
274
 
        my_config._parser = my_config._get_parser(file=config_file)
275
 
        self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
276
 
        self.assertEqual(False, my_config.signature_needed())
277
 
 
278
 
    def test_gpg_signing_command_unset(self):
279
 
        config_file = StringIO("")
280
 
        my_config = config.GlobalConfig()
281
 
        my_config._parser = my_config._get_parser(file=config_file)
282
 
        self.assertEqual("gpg", my_config.gpg_signing_command())
283
 
 
284
 
 
285
 
class TestLocationConfig(TestCase):
 
290
 
 
291
class TestLocationConfig(TestConfigItems):
286
292
 
287
293
    def test_constructs(self):
288
294
        my_config = config.LocationConfig('http://example.com')
401
407
        self.assertEqual(config.CHECK_ALWAYS,
402
408
                         self.my_config.signature_checking())
403
409
        
404
 
    def test_gpg_signing_command(self):
405
 
        self.get_location_config('/b')
406
 
        self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command())
407
 
 
408
 
    def test_gpg_signing_command_missing(self):
409
 
        self.get_location_config('/a')
410
 
        self.assertEqual("false", self.my_config.gpg_signing_command())
411
 
 
412
 
 
413
 
class TestBranchConfigItems(TestCase):
 
410
 
 
411
class TestBranchConfigItems(TestConfigItems):
414
412
 
415
413
    def test_user_id(self):
416
414
        branch = FakeBranch()
446
444
        (my_config._get_location_config().
447
445
            _get_global_config()._get_parser(config_file))
448
446
        self.assertEqual(config.CHECK_ALWAYS, my_config.signature_checking())
449
 
 
450
 
    def test_gpg_signing_command(self):
451
 
        branch = FakeBranch()
452
 
        my_config = config.BranchConfig(branch)
453
 
        config_file = StringIO(sample_config_text)
454
 
        (my_config._get_location_config().
455
 
            _get_global_config()._get_parser(config_file))
456
 
        self.assertEqual('gnome-gpg', my_config.gpg_signing_command())