~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Aaron Bentley
  • Date: 2007-12-21 18:20:48 UTC
  • mto: This revision was merged to the branch mainline in revision 3143.
  • Revision ID: abentley@panoramicfeedback.com-20071221182048-epdl0q3at7ktf74v
Implement find_bzrdir functionality

Show diffs side-by-side

added added

removed removed

Lines of Context:
591
591
        self.failUnlessExists('repo/tree2/subtree')
592
592
        self.failIfExists('repo/tree2/subtree/file')
593
593
 
 
594
    def make_foo_bar_baz(self):
 
595
        foo = self.make_branch('foo').bzrdir
 
596
        bar = self.make_branch('foo/bar').bzrdir
 
597
        baz = self.make_branch('baz').bzrdir
 
598
        return foo, bar, baz
 
599
 
 
600
    def test_find_bzrdirs(self):
 
601
        foo, bar, baz = self.make_foo_bar_baz()
 
602
        transport = get_transport(self.get_url())
 
603
        self.assertEqualBzrdirs([baz, foo, bar],
 
604
                                bzrdir.BzrDir.find_bzrdirs(transport))
 
605
 
 
606
    def test_find_bzrdirs_list_current(self):
 
607
        def list_current(transport):
 
608
            return [s for s in transport.list_dir('') if s != 'baz']
 
609
 
 
610
        foo, bar, baz = self.make_foo_bar_baz()
 
611
        transport = get_transport(self.get_url())
 
612
        self.assertEqualBzrdirs([foo, bar],
 
613
                                bzrdir.BzrDir.find_bzrdirs(transport,
 
614
                                    list_current=list_current))
 
615
 
 
616
 
 
617
    def test_find_bzrdirs_evaluate(self):
 
618
        def evaluate(bzrdir):
 
619
            try:
 
620
                repo = bzrdir.open_repository()
 
621
            except NoRepositoryPresent:
 
622
                return True, bzrdir.root_transport.base
 
623
            else:
 
624
                return False, bzrdir.root_transport.base
 
625
 
 
626
        foo, bar, baz = self.make_foo_bar_baz()
 
627
        transport = get_transport(self.get_url())
 
628
        self.assertEqual([baz.root_transport.base, foo.root_transport.base],
 
629
                         list(bzrdir.BzrDir.find_bzrdirs(transport,
 
630
                                                         evaluate=evaluate)))
 
631
 
 
632
    def assertEqualBzrdirs(self, first, second):
 
633
        first = list(first)
 
634
        second = list(second)
 
635
        self.assertEqual(len(first), len(second))
 
636
        for x, y in zip(first, second):
 
637
            self.assertEqual(x.root_transport.base, y.root_transport.base)
 
638
 
594
639
 
595
640
class TestMeta1DirFormat(TestCaseWithTransport):
596
641
    """Tests specific to the meta1 dir format."""