~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_tree/test_tree.py

  • Committer: Patch Queue Manager
  • Date: 2012-04-02 02:36:45 UTC
  • mfrom: (6471.1.7 iter-child-entries)
  • Revision ID: pqm@pqm.ubuntu.com-20120402023645-28dkcb0awh3i1flc
(jelmer) Add Tree.iter_child_entries(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
249
249
                         output_order)
250
250
 
251
251
 
 
252
class TestIterChildEntries(TestCaseWithTree):
 
253
 
 
254
    def test_iteration_order(self):
 
255
        work_tree = self.make_branch_and_tree('.')
 
256
        self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g'])
 
257
        work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g'])
 
258
        tree = self._convert_tree(work_tree)
 
259
        output = [e.name for e in
 
260
            tree.iter_child_entries(tree.get_root_id())]
 
261
        self.assertEqual(set(['a', 'f']), set(output))
 
262
        output = [e.name for e in
 
263
            tree.iter_child_entries(tree.path2id('a'))]
 
264
        self.assertEqual(set(['b', 'd']), set(output))
 
265
 
 
266
    def test_does_not_exist(self):
 
267
        work_tree = self.make_branch_and_tree('.')
 
268
        self.build_tree(['a/'])
 
269
        work_tree.add(['a'])
 
270
        tree = self._convert_tree(work_tree)
 
271
        self.assertRaises(errors.NoSuchId, lambda:
 
272
            list(tree.iter_child_entries('unknown')))
 
273
 
 
274
 
252
275
class TestHasId(TestCaseWithTree):
253
276
 
254
277
    def test_has_id(self):