~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-04 17:24:52 UTC
  • mto: This revision was merged to the branch mainline in revision 5499.
  • Revision ID: v.ladeuil+lp@free.fr-20101004172452-unu266taysseifa4
Implement ``bzr config --remove <option>``.

* bzrlib/tests/test_config.py:
(TestConfigRemoveOption): Complete the tests.

* bzrlib/tests/blackbox/test_config.py:
(TestConfigRemoveOption.test_unknown_config): Test the cmd_config
option removal.

* bzrlib/config.py:
(IniBasedConfig.get_sections): Add the configuration id to the
returned tuples or we can't implement option removal for
BranchConfig.
(IniBasedConfig.remove_user_option): Default implementation.
(LockableConfig.remove_user_option): Implementation for lockable
configs.
(BranchConfig._get_branch_data_config): Force the id for the
branch data config to avoid forcing it in TreeConfig (oh my...).
(TreeConfig.remove_option): Use a different signature to avoid
confusion with remove_user_option (geez).
(TransportConfig.remove_option): The other side of
remove_user_option for BranchConfig.
(cmd_config._remove_config_option): The working implementation for
cmd config and two unsuccesful
approaches (BranchConfig/TreeConfig/TransportConfig is a mess when
it comes to provide precise access).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1515
1515
        actual = list(conf.get_options())
1516
1516
        self.assertEqual(expected, actual)
1517
1517
 
1518
 
    # One variable in non of the above
 
1518
    # One variable in none of the above
1519
1519
    def test_no_variable(self):
1520
1520
        # Using branch should query branch, locations and bazaar
1521
1521
        self.assertOptions([], self.branch_config)
1569
1569
        super(TestConfigRemoveOption, self).setUp()
1570
1570
        create_configs_with_file_option(self)
1571
1571
 
 
1572
    def assertOptions(self, expected, conf):
 
1573
        actual = list(conf.get_options())
 
1574
        self.assertEqual(expected, actual)
 
1575
 
 
1576
    def test_remove_in_locations(self):
 
1577
        self.locations_config.remove_user_option('file', self.tree.basedir)
 
1578
        self.assertOptions(
 
1579
            [('file', 'branch', 'DEFAULT', 'branch'),
 
1580
             ('file', 'bazaar', 'DEFAULT', 'bazaar'),],
 
1581
            self.branch_config)
 
1582
 
 
1583
    def test_remove_in_branch(self):
 
1584
        self.branch_config.remove_user_option('file')
 
1585
        self.assertOptions(
 
1586
            [('file', 'locations', self.tree.basedir, 'locations'),
 
1587
             ('file', 'bazaar', 'DEFAULT', 'bazaar'),],
 
1588
            self.branch_config)
 
1589
 
 
1590
    def test_remove_in_bazaar(self):
 
1591
        self.bazaar_config.remove_user_option('file')
 
1592
        self.assertOptions(
 
1593
            [('file', 'locations', self.tree.basedir, 'locations'),
 
1594
             ('file', 'branch', 'DEFAULT', 'branch'),],
 
1595
            self.branch_config)
 
1596
 
1572
1597
 
1573
1598
class TestConfigGetSections(tests.TestCaseWithTransport):
1574
1599