/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 revspec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 
2
# -*- encoding: utf-8 -*-
2
3
#
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
91
92
        self.assertEquals("180", rev.properties['author-timezone'])
92
93
        self.assertEquals("git-v1:" + c.id, rev.revision_id)
93
94
 
 
95
    def test_explicit_encoding(self):
 
96
        c = Commit()
 
97
        c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"
 
98
        c.message = "Some message"
 
99
        c.committer = "Committer"
 
100
        c.commit_time = 4
 
101
        c.author_time = 5
 
102
        c.commit_timezone = 60 * 5
 
103
        c.author_timezone = 60 * 3
 
104
        c.author = u"Authér".encode("iso8859-1")
 
105
        c.encoding = "iso8859-1"
 
106
        c.serialize()
 
107
        rev = BzrGitMappingv1().import_commit(c)
 
108
        self.assertEquals(u"Authér", rev.properties['author'])
 
109
        self.assertEquals("iso8859-1", rev.properties["git-explicit-encoding"])
 
110
        self.assertTrue("git-implicit-encoding" not in rev.properties)
 
111
 
 
112
    def test_implicit_encoding_fallback(self):
 
113
        c = Commit()
 
114
        c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"
 
115
        c.message = "Some message"
 
116
        c.committer = "Committer"
 
117
        c.commit_time = 4
 
118
        c.author_time = 5
 
119
        c.commit_timezone = 60 * 5
 
120
        c.author_timezone = 60 * 3
 
121
        c.author = u"Authér".encode("latin1")
 
122
        c.serialize()
 
123
        rev = BzrGitMappingv1().import_commit(c)
 
124
        self.assertEquals(u"Authér", rev.properties['author'])
 
125
        self.assertEquals("latin1", rev.properties["git-implicit-encoding"])
 
126
        self.assertTrue("git-explicit-encoding" not in rev.properties)
 
127
 
 
128
    def test_implicit_encoding_utf8(self):
 
129
        c = Commit()
 
130
        c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"
 
131
        c.message = "Some message"
 
132
        c.committer = "Committer"
 
133
        c.commit_time = 4
 
134
        c.author_time = 5
 
135
        c.commit_timezone = 60 * 5
 
136
        c.author_timezone = 60 * 3
 
137
        c.author = u"Authér".encode("utf-8")
 
138
        c.serialize()
 
139
        rev = BzrGitMappingv1().import_commit(c)
 
140
        self.assertEquals(u"Authér", rev.properties['author'])
 
141
        self.assertTrue("git-explicit-encoding" not in rev.properties)
 
142
        self.assertTrue("git-implicit-encoding" not in rev.properties)
94
143
 
95
144
 
96
145
class RoundtripRevisionsFromGit(tests.TestCase):
116
165
        self.assertEquals(commit1.author_time, commit2.author_time)
117
166
        self.assertEquals(commit1.author_timezone, commit2.author_timezone)
118
167
        self.assertEquals(commit1.message, commit2.message)
 
168
        self.assertEquals(commit1.encoding, commit2.encoding)
119
169
 
120
170
    def test_commit(self):
121
171
        c = Commit()
129
179
        c.author = "Author <author>"
130
180
        self.assertRoundtripCommit(c)
131
181
 
 
182
    def test_commit_encoding(self):
 
183
        c = Commit()
 
184
        c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"
 
185
        c.message = "Some message"
 
186
        c.committer = "Committer <Committer>"
 
187
        c.encoding = 'iso8859-1'
 
188
        c.commit_time = 4
 
189
        c.commit_timezone = -60 * 3
 
190
        c.author_time = 5
 
191
        c.author_timezone = 60 * 2
 
192
        c.author = "Author <author>"
 
193
        self.assertRoundtripCommit(c)
 
194
 
132
195
 
133
196
class DirectoryToTreeTests(tests.TestCase):
134
197