~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-19 17:14:33 UTC
  • mto: This revision was merged to the branch mainline in revision 2924.
  • Revision ID: john@arbash-meinel.com-20071019171433-ko3319eemyhpb7kz
Fix bug #152360. The xml5 serializer should be using
the hint it was given about the revision id.
It was accidentally overwriting the revision_id to None when the
data did not hold a valid value.
Add tests that this is done properly, at both the Repository level
and at the xml5 layer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
</inventory>
176
176
"""
177
177
 
 
178
# Before revision_id was always stored as an attribute
 
179
_inventory_v5a = """<inventory format="5">
 
180
</inventory>
 
181
"""
 
182
 
 
183
# Before revision_id was always stored as an attribute
 
184
_inventory_v5b = """<inventory format="5" revision_id="a-rev-id">
 
185
</inventory>
 
186
"""
 
187
 
178
188
 
179
189
class TestSerializer(TestCase):
180
190
    """Test XML serialization"""
247
257
        eq(ie.name, 'bar')
248
258
        eq(inv[ie.parent_id].kind, 'directory')
249
259
 
 
260
    def test_unpack_inventory_5a(self):
 
261
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
 
262
                _inventory_v5a, revision_id='test-rev-id')
 
263
        self.assertEqual('test-rev-id', inv.root.revision)
 
264
 
 
265
    def test_unpack_inventory_5b(self):
 
266
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
 
267
                _inventory_v5b, revision_id='test-rev-id')
 
268
        self.assertEqual('a-rev-id', inv.root.revision)
 
269
 
250
270
    def test_repack_inventory_5(self):
251
271
        inp = StringIO(_committed_inv_v5)
252
272
        inv = bzrlib.xml5.serializer_v5.read_inventory(inp)