415
413
b = self.make_branch('!repo')
416
414
self.assertEqual('!repo', b.get_config().get_nickname())
418
def test_warn_if_masked(self):
419
_warning = trace.warning
422
warnings.append(args[0] % args[1:])
424
def set_option(store, warn_masked=True):
426
conf.set_user_option('example_option', repr(store), store=store,
427
warn_masked=warn_masked)
428
def assertWarning(warning):
430
self.assertEqual(0, len(warnings))
432
self.assertEqual(1, len(warnings))
433
self.assertEqual(warning, warnings[0])
434
trace.warning = warning
436
branch = self.make_branch('.')
437
conf = branch.get_config()
438
set_option(config.STORE_GLOBAL)
440
set_option(config.STORE_BRANCH)
442
set_option(config.STORE_GLOBAL)
443
assertWarning('Value "4" is masked by "3" from branch.conf')
444
set_option(config.STORE_GLOBAL, warn_masked=False)
446
set_option(config.STORE_LOCATION)
448
set_option(config.STORE_BRANCH)
449
assertWarning('Value "3" is masked by "0" from locations.conf')
450
set_option(config.STORE_BRANCH, warn_masked=False)
453
trace.warning = _warning
456
417
class TestGlobalConfigItems(TestCase):
815
776
self.my_location_config._get_option_policy(
816
777
'http://www.example.com/norecurse', 'normal_option'),
817
778
config.POLICY_NORECURSE)
819
781
def test_post_commit_default(self):
820
782
self.get_branch_config('/a/c')
1006
968
location='http://example.com/specific')
1007
969
self.assertEqual(my_config.get_user_option('option'), 'exact')
1009
def test_get_mail_client(self):
1010
config = self.get_branch_config()
1011
client = config.get_mail_client()
1012
self.assertIsInstance(client, mail_client.DefaultMail)
1014
config.set_user_option('mail_client', 'default')
1015
client = config.get_mail_client()
1016
self.assertIsInstance(client, mail_client.DefaultMail)
1018
config.set_user_option('mail_client', 'editor')
1019
client = config.get_mail_client()
1020
self.assertIsInstance(client, mail_client.Editor)
1022
config.set_user_option('mail_client', 'thunderbird')
1023
client = config.get_mail_client()
1024
self.assertIsInstance(client, mail_client.Thunderbird)
1026
config.set_user_option('mail_client', 'evolution')
1027
client = config.get_mail_client()
1028
self.assertIsInstance(client, mail_client.Evolution)
1030
config.set_user_option('mail_client', 'kmail')
1031
client = config.get_mail_client()
1032
self.assertIsInstance(client, mail_client.KMail)
1034
config.set_user_option('mail_client', 'xdg-email')
1035
client = config.get_mail_client()
1036
self.assertIsInstance(client, mail_client.XDGEmail)
1038
config.set_user_option('mail_client', 'mapi')
1039
client = config.get_mail_client()
1040
self.assertIsInstance(client, mail_client.MAPIClient)
1042
config.set_user_option('mail_client', 'firebird')
1043
self.assertRaises(errors.UnknownMailClient, config.get_mail_client)
1046
972
class TestMailAddressExtraction(TestCase):
1050
976
config.extract_email_address('Jane <jane@test.com>'))
1051
977
self.assertRaises(errors.NoEmailInUsername,
1052
978
config.extract_email_address, 'Jane Tester')
1055
class TestTreeConfig(TestCaseWithTransport):
1057
def test_get_value(self):
1058
"""Test that retreiving a value from a section is possible"""
1059
branch = self.make_branch('.')
1060
tree_config = config.TreeConfig(branch)
1061
tree_config.set_option('value', 'key', 'SECTION')
1062
tree_config.set_option('value2', 'key2')
1063
tree_config.set_option('value3-top', 'key3')
1064
tree_config.set_option('value3-section', 'key3', 'SECTION')
1065
value = tree_config.get_option('key', 'SECTION')
1066
self.assertEqual(value, 'value')
1067
value = tree_config.get_option('key2')
1068
self.assertEqual(value, 'value2')
1069
self.assertEqual(tree_config.get_option('non-existant'), None)
1070
value = tree_config.get_option('non-existant', 'SECTION')
1071
self.assertEqual(value, None)
1072
value = tree_config.get_option('non-existant', default='default')
1073
self.assertEqual(value, 'default')
1074
self.assertEqual(tree_config.get_option('key2', 'NOSECTION'), None)
1075
value = tree_config.get_option('key2', 'NOSECTION', default='default')
1076
self.assertEqual(value, 'default')
1077
value = tree_config.get_option('key3')
1078
self.assertEqual(value, 'value3-top')
1079
value = tree_config.get_option('key3', 'SECTION')
1080
self.assertEqual(value, 'value3-section')