~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.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:
802
802
        branch.unlock()
803
803
 
804
804
 
 
805
class TestSmartServerBranchRequestSetConfigOptionDict(TestLockedBranch):
 
806
 
 
807
    def setUp(self):
 
808
        TestLockedBranch.setUp(self)
 
809
        # A dict with non-ascii keys and values to exercise unicode
 
810
        # roundtripping.
 
811
        self.encoded_value_dict = (
 
812
            'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde')
 
813
        self.value_dict = {
 
814
            'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}
 
815
 
 
816
    def test_value_name(self):
 
817
        branch = self.make_branch('.')
 
818
        request = smart_branch.SmartServerBranchRequestSetConfigOptionDict(
 
819
            branch.bzrdir.root_transport)
 
820
        branch_token, repo_token = self.get_lock_tokens(branch)
 
821
        config = branch._get_config()
 
822
        result = request.execute('', branch_token, repo_token,
 
823
            self.encoded_value_dict, 'foo', '')
 
824
        self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result)
 
825
        self.assertEqual(self.value_dict, config.get_option('foo'))
 
826
        # Cleanup
 
827
        branch.unlock()
 
828
 
 
829
    def test_value_name_section(self):
 
830
        branch = self.make_branch('.')
 
831
        request = smart_branch.SmartServerBranchRequestSetConfigOptionDict(
 
832
            branch.bzrdir.root_transport)
 
833
        branch_token, repo_token = self.get_lock_tokens(branch)
 
834
        config = branch._get_config()
 
835
        result = request.execute('', branch_token, repo_token,
 
836
            self.encoded_value_dict, 'foo', 'gam')
 
837
        self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result)
 
838
        self.assertEqual(self.value_dict, config.get_option('foo', 'gam'))
 
839
        # Cleanup
 
840
        branch.unlock()
 
841
 
 
842
 
805
843
class TestSmartServerBranchRequestSetTagsBytes(TestLockedBranch):
806
844
    # Only called when the branch format and tags match [yay factory
807
845
    # methods] so only need to test straight forward cases.