~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-16 14:24:51 UTC
  • mfrom: (1913.1.6 timezone-utc-55783)
  • Revision ID: pqm@pqm.ubuntu.com-20060816142451-0c165573fe342dd5
(jam) fix bugs #56290, #55783: handle TZ=UTC correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
</revision>
58
58
"""
59
59
 
 
60
_revision_v5_utc = """\
 
61
<revision committer="Martin Pool &lt;mbp@sourcefrog.net&gt;"
 
62
    inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
 
63
    revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
 
64
    timestamp="1125907235.211783886"
 
65
    timezone="0">
 
66
<message>- start splitting code for xml (de)serialization away from objects
 
67
  preparatory to supporting multiple formats by a single library
 
68
</message>
 
69
<parents>
 
70
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92"/>
 
71
</parents>
 
72
</revision>
 
73
"""
 
74
 
60
75
_committed_inv_v5 = """<inventory>
61
76
<file file_id="bar-20050901064931-73b4b1138abc9cd2" 
62
77
      name="bar" parent_id="TREE_ROOT" 
120
135
        eq(rev.parent_ids[0],
121
136
           "mbp@sourcefrog.net-20050905063503-43948f59fa127d92")
122
137
 
 
138
    def test_unpack_revision_5_utc(self):
 
139
        inp = StringIO(_revision_v5_utc)
 
140
        rev = bzrlib.xml5.serializer_v5.read_revision(inp)
 
141
        eq = self.assertEqual
 
142
        eq(rev.committer,
 
143
           "Martin Pool <mbp@sourcefrog.net>")
 
144
        eq(len(rev.parent_ids), 1)
 
145
        eq(rev.timezone, 0)
 
146
        eq(rev.parent_ids[0],
 
147
           "mbp@sourcefrog.net-20050905063503-43948f59fa127d92")
 
148
 
123
149
    def test_unpack_inventory_5(self):
124
150
        """Unpack canned new-style inventory"""
125
151
        inp = StringIO(_committed_inv_v5)
153
179
        inv2 = bzrlib.xml5.serializer_v5.read_inventory(StringIO(outp.getvalue()))
154
180
        self.assertEqual(inv, inv2)
155
181
 
 
182
    def check_repack_revision(self, txt):
 
183
        """Check that repacking a revision yields the same information"""
 
184
        inp = StringIO(txt)
 
185
        rev = bzrlib.xml5.serializer_v5.read_revision(inp)
 
186
        outp = StringIO()
 
187
        bzrlib.xml5.serializer_v5.write_revision(rev, outp)
 
188
        outfile_contents = outp.getvalue()
 
189
        rev2 = bzrlib.xml5.serializer_v5.read_revision(StringIO(outfile_contents))
 
190
        self.assertEqual(rev, rev2)
 
191
 
156
192
    def test_repack_revision_5(self):
157
193
        """Round-trip revision to XML v5"""
158
 
        inp = StringIO(_revision_v5)
159
 
        rev = bzrlib.xml5.serializer_v5.read_revision(inp)
160
 
        outp = StringIO()
161
 
        bzrlib.xml5.serializer_v5.write_revision(rev, outp)
162
 
        outfile_contents = outp.getvalue()
163
 
        rev2 = bzrlib.xml5.serializer_v5.read_revision(StringIO(outfile_contents))
164
 
        self.assertEqual(rev, rev2)
 
194
        self.check_repack_revision(_revision_v5)
 
195
 
 
196
    def test_repack_revision_5_utc(self):
 
197
        self.check_repack_revision(_revision_v5_utc)
165
198
 
166
199
    def test_pack_revision_5(self):
167
200
        """Pack revision to XML v5"""