~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Andrew Bennetts
  • Date: 2010-05-13 16:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 5232.
  • Revision ID: andrew.bennetts@canonical.com-20100513161754-q2ak6vzjnur7f3i3
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1652
1652
        branch.unlock()
1653
1653
        self.assertFinished(client)
1654
1654
 
 
1655
    def test_set_option_with_dict(self):
 
1656
        client = FakeClient()
 
1657
        client.add_expected_call(
 
1658
            'Branch.get_stacked_on_url', ('memory:///',),
 
1659
            'error', ('NotStacked',),)
 
1660
        client.add_expected_call(
 
1661
            'Branch.lock_write', ('memory:///', '', ''),
 
1662
            'success', ('ok', 'branch token', 'repo token'))
 
1663
        encoded_dict_value = 'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde'
 
1664
        client.add_expected_call(
 
1665
            'Branch.set_config_option_dict', ('memory:///', 'branch token',
 
1666
            'repo token', encoded_dict_value, 'foo', ''),
 
1667
            'success', ())
 
1668
        client.add_expected_call(
 
1669
            'Branch.unlock', ('memory:///', 'branch token', 'repo token'),
 
1670
            'success', ('ok',))
 
1671
        transport = MemoryTransport()
 
1672
        branch = self.make_remote_branch(transport, client)
 
1673
        branch.lock_write()
 
1674
        config = branch._get_config()
 
1675
        config.set_option(
 
1676
            {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'},
 
1677
            'foo')
 
1678
        branch.unlock()
 
1679
        self.assertFinished(client)
 
1680
 
1655
1681
    def test_backwards_compat_set_option(self):
1656
1682
        self.setup_smart_server_with_call_log()
1657
1683
        branch = self.make_branch('.')
1664
1690
        self.assertLength(10, self.hpss_calls)
1665
1691
        self.assertEqual('value', branch._get_config().get_option('name'))
1666
1692
 
 
1693
    def test_backwards_compat_set_option_with_dict(self):
 
1694
        self.setup_smart_server_with_call_log()
 
1695
        branch = self.make_branch('.')
 
1696
        verb = 'Branch.set_config_option_dict'
 
1697
        self.disable_verb(verb)
 
1698
        branch.lock_write()
 
1699
        self.addCleanup(branch.unlock)
 
1700
        self.reset_smart_call_log()
 
1701
        config = branch._get_config()
 
1702
        value_dict = {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}
 
1703
        config.set_option(value_dict, 'name')
 
1704
        self.assertLength(10, self.hpss_calls)
 
1705
        self.assertEqual(value_dict, branch._get_config().get_option('name'))
 
1706
 
1667
1707
 
1668
1708
class TestBranchLockWrite(RemoteBranchTestCase):
1669
1709