414
413
b = self.make_branch('!repo')
415
414
self.assertEqual('!repo', b.get_config().get_nickname())
417
def test_warn_if_masked(self):
418
_warning = trace.warning
421
warnings.append(args[0] % args[1:])
423
def set_option(store, warn_masked=True):
425
conf.set_user_option('example_option', repr(store), store=store,
426
warn_masked=warn_masked)
427
def assertWarning(warning):
429
self.assertEqual(0, len(warnings))
431
self.assertEqual(1, len(warnings))
432
self.assertEqual(warning, warnings[0])
433
trace.warning = warning
435
branch = self.make_branch('.')
436
conf = branch.get_config()
437
set_option(config.STORE_GLOBAL)
439
set_option(config.STORE_BRANCH)
441
set_option(config.STORE_GLOBAL)
442
assertWarning('Value "4" is masked by "3" from branch.conf')
443
set_option(config.STORE_GLOBAL, warn_masked=False)
445
set_option(config.STORE_LOCATION)
447
set_option(config.STORE_BRANCH)
448
assertWarning('Value "3" is masked by "0" from locations.conf')
449
set_option(config.STORE_BRANCH, warn_masked=False)
452
trace.warning = _warning
455
417
class TestGlobalConfigItems(TestCase):
814
776
self.my_location_config._get_option_policy(
815
777
'http://www.example.com/norecurse', 'normal_option'),
816
778
config.POLICY_NORECURSE)
818
781
def test_post_commit_default(self):
819
782
self.get_branch_config('/a/c')
1013
976
config.extract_email_address('Jane <jane@test.com>'))
1014
977
self.assertRaises(errors.NoEmailInUsername,
1015
978
config.extract_email_address, 'Jane Tester')
1018
class TestTreeConfig(TestCaseWithTransport):
1020
def test_get_value(self):
1021
"""Test that retreiving a value from a section is possible"""
1022
branch = self.make_branch('.')
1023
tree_config = config.TreeConfig(branch)
1024
tree_config.set_option('value', 'key', 'SECTION')
1025
tree_config.set_option('value2', 'key2')
1026
tree_config.set_option('value3-top', 'key3')
1027
tree_config.set_option('value3-section', 'key3', 'SECTION')
1028
value = tree_config.get_option('key', 'SECTION')
1029
self.assertEqual(value, 'value')
1030
value = tree_config.get_option('key2')
1031
self.assertEqual(value, 'value2')
1032
self.assertEqual(tree_config.get_option('non-existant'), None)
1033
value = tree_config.get_option('non-existant', 'SECTION')
1034
self.assertEqual(value, None)
1035
value = tree_config.get_option('non-existant', default='default')
1036
self.assertEqual(value, 'default')
1037
self.assertEqual(tree_config.get_option('key2', 'NOSECTION'), None)
1038
value = tree_config.get_option('key2', 'NOSECTION', default='default')
1039
self.assertEqual(value, 'default')
1040
value = tree_config.get_option('key3')
1041
self.assertEqual(value, 'value3-top')
1042
value = tree_config.get_option('key3', 'SECTION')
1043
self.assertEqual(value, 'value3-section')