~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-25 17:49:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2466.
  • Revision ID: john@arbash-meinel.com-20070425174944-mti4294wv55nimd3
Add a test that we properly round-trip unicode properties.
And fix the (unreported) bug :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
979
979
                              '#   c: 2\n'
980
980
                              '#   d: 1\n'
981
981
                             )
 
982
        bundle = read_bundle(bundle_sio)
 
983
        revision_info = bundle.revisions[0]
 
984
        self.assertEqual('rev1', revision_info.revision_id)
 
985
        rev = revision_info.as_revision()
 
986
        self.assertEqual({'branch-nick':'tree', 'a':'4', 'b':'3', 'c':'2',
 
987
                          'd':'1'}, rev.properties)
 
988
 
 
989
    def test_bundle_unicode_properties(self):
 
990
        """We should be able to round trip a non-ascii property."""
 
991
        tree = self.make_branch_and_memory_tree('tree')
 
992
        tree.lock_write()
 
993
        self.addCleanup(tree.unlock)
 
994
 
 
995
        tree.add([''], ['TREE_ROOT'])
 
996
        # Revisions themselves do not require anything about revision property
 
997
        # keys, other than that they are a basestring, and do not contain
 
998
        # whitespace.
 
999
        # However, Testaments assert than they are str(), and thus should not
 
1000
        # be Unicode.
 
1001
        tree.commit('One', rev_id='rev1',
 
1002
                    revprops={'omega':u'\u03a9', 'alpha':u'\u03b1'})
 
1003
        self.b1 = tree.branch
 
1004
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
 
1005
        self.assertContainsRe(bundle_sio.getvalue(),
 
1006
                              '# properties:\n'
 
1007
                              '#   alpha: \xce\xb1\n'
 
1008
                              '#   branch-nick: tree\n'
 
1009
                              '#   omega: \xce\xa9\n'
 
1010
                             )
 
1011
        bundle = read_bundle(bundle_sio)
 
1012
        revision_info = bundle.revisions[0]
 
1013
        self.assertEqual('rev1', revision_info.revision_id)
 
1014
        rev = revision_info.as_revision()
 
1015
        self.assertEqual({'branch-nick':'tree', 'omega':u'\u03a9',
 
1016
                          'alpha':u'\u03b1'}, rev.properties)
982
1017
 
983
1018
 
984
1019
class V09BundleKnit2Tester(V08BundleTester):