~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Martin Pool
  • Date: 2011-07-04 21:10:37 UTC
  • mto: (6034.1.1 filter-tree)
  • mto: This revision was merged to the branch mainline in revision 6035.
  • Revision ID: mbp@canonical.com-20110704211037-ro3417imj3oqnqxp
Support exporting tarballs from ContentFilterTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
editor=vim
161
161
change_editor=vimdiff -of @new_path @old_path
162
162
gpg_signing_command=gnome-gpg
163
 
gpg_signing_key=DD4D5088
164
163
log_format=short
165
164
validate_signatures_in_log=true
166
165
acceptable_keys=amy
215
214
[/a/]
216
215
check_signatures=check-available
217
216
gpg_signing_command=false
218
 
gpg_signing_key=default
219
217
user_local_option=local
220
218
# test trailing / matching
221
219
[/a/*]
1227
1225
        self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
1228
1226
        self.assertEqual(False, my_config.signature_needed())
1229
1227
 
1230
 
    def test_gpg_signing_key(self):
1231
 
        my_config = self._get_sample_config()
1232
 
        self.assertEqual("DD4D5088", my_config.gpg_signing_key())
1233
 
 
1234
1228
    def _get_empty_config(self):
1235
1229
        my_config = config.GlobalConfig()
1236
1230
        return my_config
1526
1520
        self.get_branch_config('/a')
1527
1521
        self.assertEqual("false", self.my_config.gpg_signing_command())
1528
1522
 
1529
 
    def test_gpg_signing_key(self):
1530
 
        self.get_branch_config('/b')
1531
 
        self.assertEqual("DD4D5088", self.my_config.gpg_signing_key())
1532
 
 
1533
 
    def test_gpg_signing_key_default(self):
1534
 
        self.get_branch_config('/a')
1535
 
        self.assertEqual("erik@bagfors.nu", self.my_config.gpg_signing_key())
1536
 
 
1537
1523
    def test_get_user_option_global(self):
1538
1524
        self.get_branch_config('/a')
1539
1525
        self.assertEqual('something',
2219
2205
    def setUp(self):
2220
2206
        super(TestOptionRegistry, self).setUp()
2221
2207
        # Always start with an empty registry
2222
 
        self.overrideAttr(config, 'option_registry', config.OptionRegistry())
 
2208
        self.overrideAttr(config, 'option_registry', registry.Registry())
2223
2209
        self.registry = config.option_registry
2224
2210
 
2225
2211
    def test_register(self):
2226
2212
        opt = config.Option('foo')
2227
 
        self.registry.register(opt)
 
2213
        self.registry.register('foo', opt)
2228
2214
        self.assertIs(opt, self.registry.get('foo'))
2229
2215
 
 
2216
    lazy_option = config.Option('lazy_foo')
 
2217
 
 
2218
    def test_register_lazy(self):
 
2219
        self.registry.register_lazy('foo', self.__module__,
 
2220
                                    'TestOptionRegistry.lazy_option')
 
2221
        self.assertIs(self.lazy_option, self.registry.get('foo'))
 
2222
 
2230
2223
    def test_registered_help(self):
2231
 
        opt = config.Option('foo', help='A simple option')
2232
 
        self.registry.register(opt)
 
2224
        opt = config.Option('foo')
 
2225
        self.registry.register('foo', opt, help='A simple option')
2233
2226
        self.assertEquals('A simple option', self.registry.get_help('foo'))
2234
2227
 
2235
 
    lazy_option = config.Option('lazy_foo', help='Lazy help')
2236
 
 
2237
 
    def test_register_lazy(self):
2238
 
        self.registry.register_lazy('lazy_foo', self.__module__,
2239
 
                                    'TestOptionRegistry.lazy_option')
2240
 
        self.assertIs(self.lazy_option, self.registry.get('lazy_foo'))
2241
 
 
2242
 
    def test_registered_lazy_help(self):
2243
 
        self.registry.register_lazy('lazy_foo', self.__module__,
2244
 
                                    'TestOptionRegistry.lazy_option')
2245
 
        self.assertEquals('Lazy help', self.registry.get_help('lazy_foo'))
2246
 
 
2247
2228
 
2248
2229
class TestRegisteredOptions(tests.TestCase):
2249
2230
    """All registered options should verify some constraints."""
2263
2244
    def test_help_is_set(self):
2264
2245
        option_help = self.registry.get_help(self.option_name)
2265
2246
        self.assertNotEquals(None, option_help)
2266
 
        # Come on, think about the user, he really wants to know what the
 
2247
        # Come on, think about the user, he really wants to know whst the
2267
2248
        # option is about
2268
 
        self.assertIsNot(None, option_help)
2269
2249
        self.assertNotEquals('', option_help)
2270
2250
 
2271
2251
 
2872
2852
    # FIXME: This should be parametrized for all known Stack or dedicated
2873
2853
    # paramerized tests created to avoid bloating -- vila 2011-03-31
2874
2854
 
2875
 
    def overrideOptionRegistry(self):
2876
 
        self.overrideAttr(config, 'option_registry', config.OptionRegistry())
2877
 
 
2878
2855
    def test_single_config_get(self):
2879
2856
        conf = dict(foo='bar')
2880
2857
        conf_stack = config.Stack([conf])
2883
2860
    def test_get_with_registered_default_value(self):
2884
2861
        conf_stack = config.Stack([dict()])
2885
2862
        opt = config.Option('foo', default='bar')
2886
 
        self.overrideOptionRegistry()
 
2863
        self.overrideAttr(config, 'option_registry', registry.Registry())
2887
2864
        config.option_registry.register('foo', opt)
2888
2865
        self.assertEquals('bar', conf_stack.get('foo'))
2889
2866
 
2890
2867
    def test_get_without_registered_default_value(self):
2891
2868
        conf_stack = config.Stack([dict()])
2892
2869
        opt = config.Option('foo')
2893
 
        self.overrideOptionRegistry()
 
2870
        self.overrideAttr(config, 'option_registry', registry.Registry())
2894
2871
        config.option_registry.register('foo', opt)
2895
2872
        self.assertEquals(None, conf_stack.get('foo'))
2896
2873
 
2897
2874
    def test_get_without_default_value_for_not_registered(self):
2898
2875
        conf_stack = config.Stack([dict()])
2899
2876
        opt = config.Option('foo')
2900
 
        self.overrideOptionRegistry()
 
2877
        self.overrideAttr(config, 'option_registry', registry.Registry())
2901
2878
        self.assertEquals(None, conf_stack.get('foo'))
2902
2879
 
2903
2880
    def test_get_first_definition(self):