~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Aaron Bentley
  • Date: 2006-06-14 19:45:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1777.
  • Revision ID: abentley@panoramicfeedback.com-20060614194557-6b499aa1cf03f7e6
Use create_signature for signing policy, deprecate check_signatures for this

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
 
43
43
sample_always_signatures = ("[DEFAULT]\n"
44
 
                            "check_signatures=require\n")
 
44
                            "check_signatures=ignore\n"
 
45
                            "create_signatures=always")
45
46
 
46
47
 
47
48
sample_ignore_signatures = ("[DEFAULT]\n"
48
 
                            "check_signatures=ignore\n")
 
49
                            "check_signatures=require\n"
 
50
                            "create_signatures=never")
49
51
 
50
52
 
51
53
sample_maybe_signatures = ("[DEFAULT]\n"
52
 
                            "check_signatures=check-available\n")
 
54
                            "check_signatures=ignore\n"
 
55
                            "create_signatures=when-required")
53
56
 
54
57
 
55
58
sample_branches_text = ("[http://www.example.com]\n"
172
175
 
173
176
    def test_signatures_default(self):
174
177
        my_config = config.Config()
 
178
        self.assertFalse(my_config.signature_needed())
175
179
        self.assertEqual(config.CHECK_IF_POSSIBLE,
176
180
                         my_config.signature_checking())
 
181
        self.assertEqual(config.SIGN_WHEN_REQUIRED,
 
182
                         my_config.signing_policy())
177
183
 
178
184
    def test_signatures_template_method(self):
179
185
        my_config = InstrumentedConfig()
326
332
        config_file = StringIO(sample_always_signatures)
327
333
        my_config = config.GlobalConfig()
328
334
        my_config._parser = my_config._get_parser(file=config_file)
329
 
        self.assertEqual(config.CHECK_ALWAYS,
 
335
        self.assertEqual(config.CHECK_NEVER,
330
336
                         my_config.signature_checking())
 
337
        self.assertEqual(config.SIGN_ALWAYS,
 
338
                         my_config.signing_policy())
331
339
        self.assertEqual(True, my_config.signature_needed())
332
340
 
333
341
    def test_signatures_if_possible(self):
334
342
        config_file = StringIO(sample_maybe_signatures)
335
343
        my_config = config.GlobalConfig()
336
344
        my_config._parser = my_config._get_parser(file=config_file)
337
 
        self.assertEqual(config.CHECK_IF_POSSIBLE,
 
345
        self.assertEqual(config.CHECK_NEVER,
338
346
                         my_config.signature_checking())
 
347
        self.assertEqual(config.SIGN_WHEN_REQUIRED,
 
348
                         my_config.signing_policy())
339
349
        self.assertEqual(False, my_config.signature_needed())
340
350
 
341
351
    def test_signatures_ignore(self):
342
352
        config_file = StringIO(sample_ignore_signatures)
343
353
        my_config = config.GlobalConfig()
344
354
        my_config._parser = my_config._get_parser(file=config_file)
345
 
        self.assertEqual(config.CHECK_NEVER,
 
355
        self.assertEqual(config.CHECK_ALWAYS,
346
356
                         my_config.signature_checking())
 
357
        self.assertEqual(config.SIGN_NEVER,
 
358
                         my_config.signing_policy())
347
359
        self.assertEqual(False, my_config.signature_needed())
348
360
 
349
361
    def _get_sample_config(self):
495
507
    def test_signatures_not_set(self):
496
508
        self.get_location_config('http://www.example.com',
497
509
                                 global_config=sample_ignore_signatures)
498
 
        self.assertEqual(config.CHECK_NEVER,
 
510
        self.assertEqual(config.CHECK_ALWAYS,
499
511
                         self.my_config.signature_checking())
 
512
        self.assertEqual(config.SIGN_NEVER,
 
513
                         self.my_config.signing_policy())
500
514
 
501
515
    def test_signatures_never(self):
502
516
        self.get_location_config('/a/c')
609
623
        config_file = StringIO(sample_always_signatures)
610
624
        (my_config._get_location_config().
611
625
            _get_global_config()._get_parser(config_file))
612
 
        self.assertEqual(config.CHECK_ALWAYS, my_config.signature_checking())
 
626
        self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
 
627
        self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy())
 
628
        self.assertTrue(my_config.signature_needed())
613
629
 
614
630
    def test_gpg_signing_command(self):
615
631
        branch = FakeBranch()