/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_mapping.py

Add tests for generate_file_id.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        c.author_timezone = 60 * 3
98
98
        c.author = "Author"
99
99
        mapping = BzrGitMappingv1()
100
 
        rev, roundtrip_revid, verifiers = mapping.import_commit(c,
101
 
            mapping.revision_id_foreign_to_bzr)
102
 
        self.assertEquals(None, roundtrip_revid)
103
 
        self.assertEquals({}, verifiers)
 
100
        rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
104
101
        self.assertEquals("Some message", rev.message)
105
102
        self.assertEquals("Committer", rev.committer)
106
103
        self.assertEquals("Author", rev.properties['author'])
122
119
        c.author = u"Authér".encode("iso8859-1")
123
120
        c.encoding = "iso8859-1"
124
121
        mapping = BzrGitMappingv1()
125
 
        rev, roundtrip_revid, verifiers = mapping.import_commit(c,
126
 
            mapping.revision_id_foreign_to_bzr)
127
 
        self.assertEquals(None, roundtrip_revid)
128
 
        self.assertEquals({}, verifiers)
 
122
        rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
129
123
        self.assertEquals(u"Authér", rev.properties['author'])
130
124
        self.assertEquals("iso8859-1", rev.properties["git-explicit-encoding"])
131
125
        self.assertTrue("git-implicit-encoding" not in rev.properties)
141
135
        c.author_timezone = 60 * 3
142
136
        c.author = u"Authér".encode("latin1")
143
137
        mapping = BzrGitMappingv1()
144
 
        rev, roundtrip_revid, verifiers = mapping.import_commit(c,
145
 
            mapping.revision_id_foreign_to_bzr)
146
 
        self.assertEquals(None, roundtrip_revid)
147
 
        self.assertEquals({}, verifiers)
 
138
        rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
148
139
        self.assertEquals(u"Authér", rev.properties['author'])
149
140
        self.assertEquals("latin1", rev.properties["git-implicit-encoding"])
150
141
        self.assertTrue("git-explicit-encoding" not in rev.properties)
160
151
        c.author_timezone = 60 * 3
161
152
        c.author = u"Authér".encode("utf-8")
162
153
        mapping = BzrGitMappingv1()
163
 
        rev, roundtrip_revid, verifiers = mapping.import_commit(c,
164
 
            mapping.revision_id_foreign_to_bzr)
165
 
        self.assertEquals(None, roundtrip_revid)
166
 
        self.assertEquals({}, verifiers)
 
154
        rev = mapping.import_commit(c, mapping.revision_id_foreign_to_bzr)
167
155
        self.assertEquals(u"Authér", rev.properties['author'])
168
156
        self.assertTrue("git-explicit-encoding" not in rev.properties)
169
157
        self.assertTrue("git-implicit-encoding" not in rev.properties)
179
167
 
180
168
    def assertRoundtripRevision(self, orig_rev):
181
169
        commit = self.mapping.export_commit(orig_rev, "mysha",
182
 
            self._lookup_parent, True, "testamentsha")
183
 
        rev, roundtrip_revid, verifiers = self.mapping.import_commit(
184
 
            commit, self.mapping.revision_id_foreign_to_bzr)
185
 
        self.assertEquals(rev.revision_id,
186
 
            self.mapping.revision_id_foreign_to_bzr(commit.id))
 
170
            self._lookup_parent, True)
 
171
        rev = self.mapping.import_commit(commit,
 
172
            self.mapping.revision_id_foreign_to_bzr)
187
173
        if self.mapping.roundtripping:
188
 
            self.assertEquals({"testament3-sha1": "testamentsha"} , verifiers)
189
 
            self.assertEquals(orig_rev.revision_id, roundtrip_revid)
 
174
            self.assertEquals(orig_rev.revision_id, rev.revision_id)
190
175
            self.assertEquals(orig_rev.properties, rev.properties)
191
176
            self.assertEquals(orig_rev.committer, rev.committer)
192
177
            self.assertEquals(orig_rev.timestamp, rev.timestamp)
193
178
            self.assertEquals(orig_rev.timezone, rev.timezone)
194
179
            self.assertEquals(orig_rev.message, rev.message)
195
180
            self.assertEquals(list(orig_rev.parent_ids), list(rev.parent_ids))
196
 
        else:
197
 
            self.assertEquals({}, verifiers)
198
181
 
199
182
    def test_simple_commit(self):
200
183
        r = Revision(self.mapping.revision_id_foreign_to_bzr("edf99e6c56495c620f20d5dacff9859ff7119261"))
250
233
        raise NotImplementedError(self.assertRoundtripBlob)
251
234
 
252
235
    def assertRoundtripCommit(self, commit1):
253
 
        rev, roundtrip_revid, verifiers = self.mapping.import_commit(
254
 
            commit1, self.mapping.revision_id_foreign_to_bzr)
 
236
        rev = self.mapping.import_commit(commit1,
 
237
            self.mapping.revision_id_foreign_to_bzr)
255
238
        commit2 = self.mapping.export_commit(rev, "12341212121212", None,
256
 
            True, None)
 
239
            True)
257
240
        self.assertEquals(commit1.committer, commit2.committer)
258
241
        self.assertEquals(commit1.commit_time, commit2.commit_time)
259
242
        self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)