/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

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:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
22
 
from ....bzr.inventory import (
23
 
    InventoryDirectory,
24
 
    InventoryFile,
25
 
    )
26
22
from ....revision import (
27
23
    Revision,
28
24
    )
42
38
from ..errors import UnknownCommitExtra
43
39
from ..mapping import (
44
40
    BzrGitMappingv1,
45
 
    directory_to_tree,
46
41
    escape_file_id,
47
42
    fix_person_identifier,
48
43
    unescape_file_id,
398
393
        self.assertRoundtripCommit(c)
399
394
 
400
395
 
401
 
class DirectoryToTreeTests(tests.TestCase):
402
 
 
403
 
    def test_empty(self):
404
 
        t = directory_to_tree({}, None, {}, None, allow_empty=False)
405
 
        self.assertEquals(None, t)
406
 
 
407
 
    def test_empty_dir(self):
408
 
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
409
 
        children = {'bar': child_ie}
410
 
        t = directory_to_tree(children, lambda x: None, {}, None,
411
 
                allow_empty=False)
412
 
        self.assertEquals(None, t)
413
 
 
414
 
    def test_empty_dir_dummy_files(self):
415
 
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
416
 
        children = {'bar':child_ie}
417
 
        t = directory_to_tree(children, lambda x: None, {}, ".mydummy",
418
 
                allow_empty=False)
419
 
        self.assertTrue(".mydummy" in t)
420
 
 
421
 
    def test_empty_root(self):
422
 
        child_ie = InventoryDirectory('bar', 'bar', 'bar')
423
 
        children = {'bar': child_ie}
424
 
        t = directory_to_tree(children, lambda x: None, {}, None,
425
 
                allow_empty=True)
426
 
        self.assertEquals(Tree(), t)
427
 
 
428
 
    def test_with_file(self):
429
 
        child_ie = InventoryFile('bar', 'bar', 'bar')
430
 
        children = {"bar": child_ie}
431
 
        b = Blob.from_string("bla")
432
 
        t1 = directory_to_tree(children, lambda x: b.id, {}, None,
433
 
                allow_empty=False)
434
 
        t2 = Tree()
435
 
        t2.add("bar", 0100644, b.id)
436
 
        self.assertEquals(t1, t2)
437
 
 
438
 
 
439
396
class FixPersonIdentifierTests(tests.TestCase):
440
397
 
441
398
    def test_valid(self):