1225
1227
self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
1226
1228
self.assertEqual(False, my_config.signature_needed())
1230
def test_gpg_signing_key(self):
1231
my_config = self._get_sample_config()
1232
self.assertEqual("DD4D5088", my_config.gpg_signing_key())
1228
1234
def _get_empty_config(self):
1229
1235
my_config = config.GlobalConfig()
1230
1236
return my_config
1520
1526
self.get_branch_config('/a')
1521
1527
self.assertEqual("false", self.my_config.gpg_signing_command())
1529
def test_gpg_signing_key(self):
1530
self.get_branch_config('/b')
1531
self.assertEqual("DD4D5088", self.my_config.gpg_signing_key())
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())
1523
1537
def test_get_user_option_global(self):
1524
1538
self.get_branch_config('/a')
1525
1539
self.assertEqual('something',
2205
2219
def setUp(self):
2206
2220
super(TestOptionRegistry, self).setUp()
2207
2221
# Always start with an empty registry
2208
self.overrideAttr(config, 'option_registry', registry.Registry())
2222
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
2209
2223
self.registry = config.option_registry
2211
2225
def test_register(self):
2212
2226
opt = config.Option('foo')
2213
self.registry.register('foo', opt)
2227
self.registry.register(opt)
2214
2228
self.assertIs(opt, self.registry.get('foo'))
2216
lazy_option = config.Option('lazy_foo')
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'))
2223
2230
def test_registered_help(self):
2224
opt = config.Option('foo')
2225
self.registry.register('foo', opt, help='A simple option')
2231
opt = config.Option('foo', help='A simple option')
2232
self.registry.register(opt)
2226
2233
self.assertEquals('A simple option', self.registry.get_help('foo'))
2235
lazy_option = config.Option('lazy_foo', help='Lazy help')
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'))
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'))
2229
2248
class TestRegisteredOptions(tests.TestCase):
2230
2249
"""All registered options should verify some constraints."""
2244
2263
def test_help_is_set(self):
2245
2264
option_help = self.registry.get_help(self.option_name)
2246
2265
self.assertNotEquals(None, option_help)
2247
# Come on, think about the user, he really wants to know whst the
2266
# Come on, think about the user, he really wants to know what the
2248
2267
# option is about
2268
self.assertIsNot(None, option_help)
2249
2269
self.assertNotEquals('', option_help)
2852
2872
# FIXME: This should be parametrized for all known Stack or dedicated
2853
2873
# paramerized tests created to avoid bloating -- vila 2011-03-31
2875
def overrideOptionRegistry(self):
2876
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
2855
2878
def test_single_config_get(self):
2856
2879
conf = dict(foo='bar')
2857
2880
conf_stack = config.Stack([conf])
2860
2883
def test_get_with_registered_default_value(self):
2861
2884
conf_stack = config.Stack([dict()])
2862
2885
opt = config.Option('foo', default='bar')
2863
self.overrideAttr(config, 'option_registry', registry.Registry())
2886
self.overrideOptionRegistry()
2864
2887
config.option_registry.register('foo', opt)
2865
2888
self.assertEquals('bar', conf_stack.get('foo'))
2867
2890
def test_get_without_registered_default_value(self):
2868
2891
conf_stack = config.Stack([dict()])
2869
2892
opt = config.Option('foo')
2870
self.overrideAttr(config, 'option_registry', registry.Registry())
2893
self.overrideOptionRegistry()
2871
2894
config.option_registry.register('foo', opt)
2872
2895
self.assertEquals(None, conf_stack.get('foo'))
2874
2897
def test_get_without_default_value_for_not_registered(self):
2875
2898
conf_stack = config.Stack([dict()])
2876
2899
opt = config.Option('foo')
2877
self.overrideAttr(config, 'option_registry', registry.Registry())
2900
self.overrideOptionRegistry()
2878
2901
self.assertEquals(None, conf_stack.get('foo'))
2880
2903
def test_get_first_definition(self):