/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_object_store.py

Avoid using file ids in object store code.

Merged from https://code.launchpad.net/~jelmer/brz-git/no-push-file-ids/+merge/342827

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from dulwich.objects import (
22
22
    Blob,
 
23
    Tree,
23
24
    )
24
25
 
25
26
from ....branchbuilder import (
26
27
    BranchBuilder,
27
28
    )
 
29
from ....bzr.inventory import (
 
30
    InventoryDirectory,
 
31
    InventoryFile,
 
32
    )
28
33
from ....errors import (
29
34
    NoSuchRevision,
30
35
    )
43
48
from ..object_store import (
44
49
    BazaarObjectStore,
45
50
    LRUTreeCache,
 
51
    directory_to_tree,
46
52
    _check_expected_sha,
47
53
    _find_missing_bzr_revids,
48
54
    _tree_to_objects,
209
215
        self.addCleanup(tree.lock_read().unlock)
210
216
        entries = list(_tree_to_objects(tree, [tree], self.idmap, {}))
211
217
        self.assertEquals([], entries)
 
218
 
 
219
 
 
220
class DirectoryToTreeTests(TestCase):
 
221
 
 
222
    def test_empty(self):
 
223
        t = directory_to_tree('', [], None, {}, None, allow_empty=False)
 
224
        self.assertEquals(None, t)
 
225
 
 
226
    def test_empty_dir(self):
 
227
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
 
228
        t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None,
 
229
                allow_empty=False)
 
230
        self.assertEquals(None, t)
 
231
 
 
232
    def test_empty_dir_dummy_files(self):
 
233
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
 
234
        t = directory_to_tree('', [child_ie], lambda p, x: None, {}, ".mydummy",
 
235
                allow_empty=False)
 
236
        self.assertTrue(".mydummy" in t)
 
237
 
 
238
    def test_empty_root(self):
 
239
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
 
240
        t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None,
 
241
                allow_empty=True)
 
242
        self.assertEquals(Tree(), t)
 
243
 
 
244
    def test_with_file(self):
 
245
        child_ie = InventoryFile('bar', 'bar', 'bar')
 
246
        b = Blob.from_string("bla")
 
247
        t1 = directory_to_tree('', [child_ie], lambda p, x: b.id, {}, None,
 
248
                allow_empty=False)
 
249
        t2 = Tree()
 
250
        t2.add("bar", 0100644, b.id)
 
251
        self.assertEquals(t1, t2)