1227
1225
self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
1228
1226
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())
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())
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())
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
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'))
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'))
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'))
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'))
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)
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
2875
def overrideOptionRegistry(self):
2876
self.overrideAttr(config, 'option_registry', config.OptionRegistry())
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'))
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'))
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'))
2903
2880
def test_get_first_definition(self):