~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_add.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    inventory,
22
22
    tests,
23
23
    )
 
24
from bzrlib.tests.matchers import HasLayout
24
25
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
25
26
 
26
27
 
27
28
class TestAdd(TestCaseWithWorkingTree):
28
29
 
29
 
    def get_tree_layout(self, tree):
30
 
        """Get the (path, file_id) pairs for the current tree."""
31
 
        tree.lock_read()
32
 
        try:
33
 
            return [(path, ie.file_id) for path, ie
34
 
                    in tree.iter_entries_by_dir()]
35
 
        finally:
36
 
            tree.unlock()
37
 
 
38
30
    def assertTreeLayout(self, expected, tree):
39
31
        """Check that the tree has the correct layout."""
40
 
        actual = self.get_tree_layout(tree)
41
 
        self.assertEqual(expected, actual)
 
32
        self.assertThat(tree, HasLayout(expected))
42
33
 
43
34
    def test_add_one(self):
44
35
        tree = self.make_branch_and_tree('.')
110
101
        tree.add(['dir/subdir/foo'], ['foo-id'])
111
102
        root_id = tree.get_root_id()
112
103
 
113
 
        self.assertTreeLayout([('', root_id), ('dir', 'dir-id'),
114
 
                               ('dir/subdir', 'subdir-id'),
 
104
        self.assertTreeLayout([('', root_id), ('dir/', 'dir-id'),
 
105
                               ('dir/subdir/', 'subdir-id'),
115
106
                               ('dir/subdir/foo', 'foo-id')], tree)
116
107
 
117
108
    def test_add_multiple(self):
122
113
        root_id = tree.get_root_id()
123
114
 
124
115
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
125
 
                               ('dir', 'dir-id'), ('dir/subdir', 'subdir-id'),
 
116
                               ('dir/', 'dir-id'), ('dir/subdir/', 'subdir-id'),
126
117
                               ('dir/subdir/foo', 'foo-id')], tree)
127
118
 
128
119
    def test_add_invalid(self):