/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

Simply refer to bzr's docs in HACKING.

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
 
17
22
from dulwich.objects import (
 
23
    Blob,
18
24
    Commit,
 
25
    Tree,
19
26
    )
20
27
 
21
28
from bzrlib.plugins.git import tests
22
29
from bzrlib.plugins.git.mapping import (
23
30
    BzrGitMappingv1,
 
31
    directory_to_tree,
24
32
    escape_file_id,
25
33
    revision_to_commit,
26
34
    unescape_file_id,
122
130
        c.author = "Author <author>"
123
131
        self.assertRoundtripCommit(c)
124
132
 
 
133
 
 
134
class DirectoryToTreeTests(tests.TestCase):
 
135
 
 
136
    def test_empty(self):
 
137
        ie = InventoryDirectory('foo', 'foo', 'foo')
 
138
        t = directory_to_tree(ie, None, {})
 
139
        self.assertEquals(None, t)
 
140
 
 
141
    def test_empty_dir(self):
 
142
        ie = InventoryDirectory('foo', 'foo', 'foo')
 
143
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
 
144
        ie.children['bar'] = child_ie
 
145
        t = directory_to_tree(ie, lambda x: None, {})
 
146
        self.assertEquals(None, t)
 
147
 
 
148
    def test_empty_root(self):
 
149
        ie = InventoryDirectory('foo', 'foo', None)
 
150
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
 
151
        ie.children['bar'] = child_ie
 
152
        t = directory_to_tree(ie, lambda x: None, {})
 
153
        self.assertEquals(Tree(), t)
 
154
 
 
155
    def test_with_file(self):
 
156
        ie = InventoryDirectory('foo', 'foo', 'foo')
 
157
        child_ie = InventoryFile('bar', 'bar', 'bar')
 
158
        ie.children['bar'] = child_ie
 
159
        b = Blob.from_string("bla")
 
160
        t1 = directory_to_tree(ie, lambda x: b.id, {})
 
161
        t2 = Tree()
 
162
        t2.add(0100644, "bar", b.id)
 
163
        self.assertEquals(t1, t2)