/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

More tests for sha maps, fix cache misses in tdb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.inventory import (
18
 
    InventoryDirectory,
19
 
    InventoryFile,
20
 
    )
21
 
 
22
17
from dulwich.objects import (
23
 
    Blob,
24
18
    Commit,
25
 
    Tree,
26
19
    )
27
20
 
28
21
from bzrlib.plugins.git import tests
29
22
from bzrlib.plugins.git.mapping import (
30
23
    BzrGitMappingv1,
31
 
    directory_to_tree,
32
24
    escape_file_id,
 
25
    revision_to_commit,
33
26
    unescape_file_id,
34
27
    )
35
28
 
108
101
    def assertRoundtripCommit(self, commit1):
109
102
        commit1.serialize()
110
103
        rev = self.mapping.import_commit(commit1)
111
 
        commit2 = self.mapping.export_commit(rev, "12341212121212", None)
 
104
        commit2 = revision_to_commit(rev, "12341212121212", None)
112
105
        self.assertEquals(commit1.committer, commit2.committer)
113
106
        self.assertEquals(commit1.commit_time, commit2.commit_time)
114
107
        self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)
129
122
        c.author = "Author <author>"
130
123
        self.assertRoundtripCommit(c)
131
124
 
132
 
 
133
 
class DirectoryToTreeTests(tests.TestCase):
134
 
 
135
 
    def test_empty(self):
136
 
        ie = InventoryDirectory('foo', 'foo', 'foo')
137
 
        t = directory_to_tree(ie, None, {})
138
 
        self.assertEquals(None, t)
139
 
 
140
 
    def test_empty_dir(self):
141
 
        ie = InventoryDirectory('foo', 'foo', 'foo')
142
 
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
143
 
        ie.children['bar'] = child_ie
144
 
        t = directory_to_tree(ie, lambda x: None, {})
145
 
        self.assertEquals(None, t)
146
 
 
147
 
    def test_empty_root(self):
148
 
        ie = InventoryDirectory('foo', 'foo', None)
149
 
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
150
 
        ie.children['bar'] = child_ie
151
 
        t = directory_to_tree(ie, lambda x: None, {})
152
 
        self.assertEquals(Tree(), t)
153
 
 
154
 
    def test_with_file(self):
155
 
        ie = InventoryDirectory('foo', 'foo', 'foo')
156
 
        child_ie = InventoryFile('bar', 'bar', 'bar')
157
 
        ie.children['bar'] = child_ie
158
 
        b = Blob.from_string("bla")
159
 
        t1 = directory_to_tree(ie, lambda x: b.id, {})
160
 
        t2 = Tree()
161
 
        t2.add(0100644, "bar", b.id)
162
 
        self.assertEquals(t1, t2)