655
656
def test_file_has_text(self):
656
657
file = inventory.InventoryFile('123', 'hello.c', ROOT_ID)
657
self.failUnless(file.has_text())
658
self.assertTrue(file.has_text())
659
660
def test_directory_has_text(self):
660
661
dir = inventory.InventoryDirectory('123', 'hello.c', ROOT_ID)
661
self.failIf(dir.has_text())
662
self.assertFalse(dir.has_text())
663
664
def test_link_has_text(self):
664
665
link = inventory.InventoryLink('123', 'hello.c', ROOT_ID)
665
self.failIf(link.has_text())
666
self.assertFalse(link.has_text())
667
668
def test_make_entry(self):
668
669
self.assertIsInstance(inventory.make_entry("file", "name", ROOT_ID),
1436
1437
inv = self.make_simple_inventory()
1437
1438
self.assertExpand(['TREE_ROOT', 'dir1-id', 'sub-dir1-id', 'top-id',
1438
1439
'subsub-file1-id'], inv, ['top-id', 'subsub-file1-id'])
1442
class TestMutableInventoryFromTree(TestCaseWithTransport):
1444
def test_empty(self):
1445
repository = self.make_repository('.')
1446
tree = repository.revision_tree(revision.NULL_REVISION)
1447
inv = mutable_inventory_from_tree(tree)
1448
self.assertEquals(revision.NULL_REVISION, inv.revision_id)
1449
self.assertEquals(0, len(inv))
1451
def test_some_files(self):
1452
wt = self.make_branch_and_tree('.')
1453
self.build_tree(['a'])
1454
wt.add(['a'], ['thefileid'])
1455
revid = wt.commit("commit")
1456
tree = wt.branch.repository.revision_tree(revid)
1457
inv = mutable_inventory_from_tree(tree)
1458
self.assertEquals(revid, inv.revision_id)
1459
self.assertEquals(2, len(inv))
1460
self.assertEquals("a", inv['thefileid'].name)
1461
# The inventory should be mutable and independent of
1463
self.assertFalse(tree.inventory['thefileid'].executable)
1464
inv['thefileid'].executable = True
1465
self.assertFalse(tree.inventory['thefileid'].executable)