~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_test_trees.py

  • Committer: Robert Collins
  • Date: 2006-07-25 06:19:05 UTC
  • mto: (1852.7.4 split-tree-source)
  • mto: This revision was merged to the branch mainline in revision 1890.
  • Revision ID: robertc@robertcollins.net-20060725061905-b1ab0530dcca0238
Add more test trees to the tree-implementations tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        self.assertEqual([], tree.conflicts())
29
29
        self.assertEqual([], list(tree.unknowns()))
30
30
        self.assertEqual([inventory.ROOT_ID], list(iter(tree)))
 
31
        self.assertEqual(
 
32
            [('', inventory.ROOT_ID)],
 
33
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
34
 
 
35
    def test_abc_tree_no_parents(self):
 
36
        tree = self.get_tree_no_parents_abc_content()
 
37
        self.assertEqual([], tree.get_parent_ids())
 
38
        self.assertEqual([], tree.conflicts())
 
39
        self.assertEqual([], list(tree.unknowns()))
 
40
        # __iter__ has no strongly defined order
 
41
        self.assertEqual(
 
42
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
43
            set(iter(tree)))
 
44
        self.assertEqual(
 
45
            [('', inventory.ROOT_ID), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
 
46
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
47
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
 
48
        self.assertFalse(tree.is_executable('c-id'))
 
49
 
 
50
    def test_abc_tree_content_2_no_parents(self):
 
51
        tree = self.get_tree_no_parents_abc_content_2()
 
52
        self.assertEqual([], tree.get_parent_ids())
 
53
        self.assertEqual([], tree.conflicts())
 
54
        self.assertEqual([], list(tree.unknowns()))
 
55
        # __iter__ has no strongly defined order
 
56
        self.assertEqual(
 
57
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
58
            set(iter(tree)))
 
59
        self.assertEqual(
 
60
            [('', inventory.ROOT_ID), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
 
61
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
62
        self.assertEqualDiff('foobar\n', tree.get_file_text('a-id'))
 
63
        self.assertFalse(tree.is_executable('c-id'))
 
64
        
 
65
    def test_abc_tree_content_3_no_parents(self):
 
66
        tree = self.get_tree_no_parents_abc_content_3()
 
67
        self.assertEqual([], tree.get_parent_ids())
 
68
        self.assertEqual([], tree.conflicts())
 
69
        self.assertEqual([], list(tree.unknowns()))
 
70
        # __iter__ has no strongly defined order
 
71
        self.assertEqual(
 
72
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
73
            set(iter(tree)))
 
74
        self.assertEqual(
 
75
            [('', inventory.ROOT_ID), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
 
76
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
77
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
 
78
        self.assertTrue(tree.is_executable('c-id'))
 
79
        
 
80
    def test_abc_tree_content_4_no_parents(self):
 
81
        tree = self.get_tree_no_parents_abc_content_4()
 
82
        self.assertEqual([], tree.get_parent_ids())
 
83
        self.assertEqual([], tree.conflicts())
 
84
        self.assertEqual([], list(tree.unknowns()))
 
85
        # __iter__ has no strongly defined order
 
86
        self.assertEqual(
 
87
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
88
            set(iter(tree)))
 
89
        self.assertEqual(
 
90
            [('', inventory.ROOT_ID), ('b', 'b-id'), ('d', 'a-id'), ('b/c', 'c-id')],
 
91
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
92
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
 
93
        self.assertFalse(tree.is_executable('c-id'))
 
94
        
 
95
    def test_abc_tree_content_5_no_parents(self):
 
96
        tree = self.get_tree_no_parents_abc_content_5()
 
97
        self.assertEqual([], tree.get_parent_ids())
 
98
        self.assertEqual([], tree.conflicts())
 
99
        self.assertEqual([], list(tree.unknowns()))
 
100
        # __iter__ has no strongly defined order
 
101
        self.assertEqual(
 
102
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
103
            set(iter(tree)))
 
104
        self.assertEqual(
 
105
            [('', inventory.ROOT_ID), ('b', 'b-id'), ('d', 'a-id'), ('b/c', 'c-id')],
 
106
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
107
        self.assertEqualDiff('bar\n', tree.get_file_text('a-id'))
 
108
        self.assertFalse(tree.is_executable('c-id'))
 
109
        
 
110
    def test_abc_tree_content_6_no_parents(self):
 
111
        tree = self.get_tree_no_parents_abc_content_6()
 
112
        self.assertEqual([], tree.get_parent_ids())
 
113
        self.assertEqual([], tree.conflicts())
 
114
        self.assertEqual([], list(tree.unknowns()))
 
115
        # __iter__ has no strongly defined order
 
116
        self.assertEqual(
 
117
            set([inventory.ROOT_ID, 'a-id', 'b-id', 'c-id']),
 
118
            set(iter(tree)))
 
119
        self.assertEqual(
 
120
            [('', inventory.ROOT_ID), ('a', 'a-id'), ('b', 'b-id'), ('e', 'c-id')],
 
121
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
 
122
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
 
123
        self.assertTrue(tree.is_executable('c-id'))