~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testconfig.py

  • Committer: Aaron Bentley
  • Date: 2005-10-18 19:47:04 UTC
  • mfrom: (1460)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1474.
  • Revision ID: abentley@panoramicfeedback.com-20051018194704-47d6827cc1d0d11b
Merged more config stuff from Robert

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"
60
61
                        "# test trailing / matching\n"
61
62
                        "[/a/*]\n"
62
63
                        "#subdirs will match but not the parent\n"
143
144
                         my_config.signature_checking())
144
145
        self.assertEqual(['_get_signature_checking'], my_config._calls)
145
146
 
 
147
    def test_gpg_signing_command_default(self):
 
148
        my_config = config.Config()
 
149
        self.assertEqual('gpg', my_config.gpg_signing_command())
 
150
 
146
151
 
147
152
class TestConfigPath(TestCase):
148
153
 
153
158
 
154
159
    def tearDown(self):
155
160
        os.environ['HOME'] = self.oldenv
 
161
        super(TestConfigPath, self).tearDown()
156
162
    
157
163
    def test_config_dir(self):
158
164
        self.assertEqual(config.config_dir(), '/home/bogus/.bazaar')
186
192
        self.failUnless(my_config._get_parser() is parser)
187
193
 
188
194
 
189
 
 
190
195
class TestGetConfig(TestCase):
191
196
 
192
197
    def test_constructs(self):
222
227
        self.failUnless(location_config is my_config._get_location_config())
223
228
 
224
229
 
225
 
class TestConfigItems(TestCase):
226
 
 
227
 
    def setUp(self):
228
 
        super(TestConfigItems, self).setUp()
229
 
        self.bzr_email = os.environ.get('BZREMAIL')
230
 
        if self.bzr_email is not None:
231
 
            del os.environ['BZREMAIL']
232
 
        self.email = os.environ.get('EMAIL')
233
 
        if self.email is not None:
234
 
            del os.environ['EMAIL']
235
 
        self.oldenv = os.environ.get('HOME', None)
236
 
        os.environ['HOME'] = os.getcwd()
237
 
 
238
 
    def tearDown(self):
239
 
        os.environ['HOME'] = self.oldenv
240
 
        if os.environ.get('BZREMAIL') is not None:
241
 
            del os.environ['BZREMAIL']
242
 
        if self.bzr_email is not None:
243
 
            os.environ['BZREMAIL'] = self.bzr_email
244
 
        if self.email is not None:
245
 
            os.environ['EMAIL'] = self.email
246
 
        super(TestConfigItems, self).tearDown()
247
 
 
248
 
 
249
 
class TestGlobalConfigItems(TestConfigItems):
 
230
class TestGlobalConfigItems(TestCase):
250
231
 
251
232
    def test_user_id(self):
252
233
        config_file = StringIO(sample_config_text)
291
272
                         my_config.signature_checking())
292
273
        self.assertEqual(False, my_config.signature_needed())
293
274
 
294
 
 
295
 
class TestLocationConfig(TestConfigItems):
 
275
    def test_gpg_signing_command(self):
 
276
        config_file = StringIO(sample_config_text)
 
277
        my_config = config.GlobalConfig()
 
278
        my_config._parser = my_config._get_parser(file=config_file)
 
279
        self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
 
280
        self.assertEqual(False, my_config.signature_needed())
 
281
 
 
282
    def test_gpg_signing_command_unset(self):
 
283
        config_file = StringIO("")
 
284
        my_config = config.GlobalConfig()
 
285
        my_config._parser = my_config._get_parser(file=config_file)
 
286
        self.assertEqual("gpg", my_config.gpg_signing_command())
 
287
 
 
288
 
 
289
class TestLocationConfig(TestCase):
296
290
 
297
291
    def test_constructs(self):
298
292
        my_config = config.LocationConfig('http://example.com')
413
407
        self.assertEqual(config.CHECK_ALWAYS,
414
408
                         self.my_config.signature_checking())
415
409
        
416
 
 
417
 
class TestBranchConfigItems(TestConfigItems):
 
410
    def test_gpg_signing_command(self):
 
411
        self.get_location_config('/b')
 
412
        self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command())
 
413
 
 
414
    def test_gpg_signing_command_missing(self):
 
415
        self.get_location_config('/a')
 
416
        self.assertEqual("false", self.my_config.gpg_signing_command())
 
417
 
 
418
 
 
419
class TestBranchConfigItems(TestCase):
418
420
 
419
421
    def test_user_id(self):
420
422
        branch = FakeBranch()
450
452
        (my_config._get_location_config().
451
453
            _get_global_config()._get_parser(config_file))
452
454
        self.assertEqual(config.CHECK_ALWAYS, my_config.signature_checking())
 
455
 
 
456
    def test_gpg_signing_command(self):
 
457
        branch = FakeBranch()
 
458
        my_config = config.BranchConfig(branch)
 
459
        config_file = StringIO(sample_config_text)
 
460
        (my_config._get_location_config().
 
461
            _get_global_config()._get_parser(config_file))
 
462
        self.assertEqual('gnome-gpg', my_config.gpg_signing_command())