497
497
super(TestBranchOptions, self).setUp()
498
498
self.branch = self.make_branch('.')
499
499
self.config = self.branch.get_config()
502
self.warnings.append(args[0] % args[1:])
503
self.overrideAttr(trace, 'warning', warning)
505
def check_aro_is(self, expected_value, value=None, check_warn=False):
501
def check_append_revisions_only(self, expected_value, value=None):
502
"""Set append_revisions_only in config and check its interpretation."""
506
503
if value is not None:
507
504
self.config.set_user_option('append_revisions_only', value)
510
505
self.assertEqual(expected_value,
511
506
self.branch._get_append_revisions_only())
513
msg = ('Value "%s" is not a boolean for "append_revisions_only"')
514
self.assertLength(1, self.warnings)
515
self.assertEqual(msg % value, self.warnings[0])
517
508
def test_valid_append_revisions_only(self):
518
509
self.assertEquals(None,
519
510
self.config.get_user_option('append_revisions_only'))
520
self.check_aro_is(None)
521
self.check_aro_is(False, 'False')
522
self.check_aro_is(True, 'True')
511
self.check_append_revisions_only(None)
512
self.check_append_revisions_only(False, 'False')
513
self.check_append_revisions_only(True, 'True')
523
514
# The following values will cause compatibility problems on projects
524
515
# using older bzr versions (<2.2) but are accepted
525
self.check_aro_is(False, 'false')
526
self.check_aro_is(True, 'true')
516
self.check_append_revisions_only(False, 'false')
517
self.check_append_revisions_only(True, 'true')
528
519
def test_invalid_append_revisions_only(self):
529
520
"""Ensure warning is noted on invalid settings"""
530
self.check_aro_is(None, 'not-a-bool', check_warn=True)
523
self.warnings.append(args[0] % args[1:])
524
self.overrideAttr(trace, 'warning', warning)
525
self.check_append_revisions_only(None, 'not-a-bool')
526
self.assertLength(1, self.warnings)
528
'Value "not-a-bool" is not a boolean for "append_revisions_only"',
533
532
class TestPullResult(TestCase):