~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-02-07 03:09:58 UTC
  • mfrom: (2268 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2269.
  • Revision ID: aaron.bentley@utoronto.ca-20070207030958-fx6ykp7rg7zma6xu
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
For interface contract tests, see tests/bzr_dir_implementations.
20
20
"""
21
21
 
 
22
import os.path
22
23
from StringIO import StringIO
23
24
 
24
25
from bzrlib import (
25
26
    help_topics,
26
27
    symbol_versioning,
 
28
    urlutils,
27
29
    )
28
30
import bzrlib.branch
29
31
import bzrlib.bzrdir as bzrdir
33
35
                           UnsupportedFormatError,
34
36
                           )
35
37
import bzrlib.repository as repository
36
 
from bzrlib.tests import TestCase, TestCaseWithTransport
 
38
from bzrlib.tests import TestCase, TestCaseWithTransport, test_sftp_transport
37
39
from bzrlib.tests.HttpServer import HttpServer
38
40
from bzrlib.transport import get_transport
39
41
from bzrlib.transport.memory import MemoryServer
422
424
            get_transport(self.get_readonly_url('g/p/q')))
423
425
        self.assertEqual('g/p/q', relpath)
424
426
 
 
427
    def test_open_containing_tree_or_branch(self):
 
428
        def local_branch_path(branch):
 
429
             return os.path.realpath(
 
430
                urlutils.local_path_from_url(branch.base))
 
431
 
 
432
        self.make_branch_and_tree('topdir')
 
433
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
434
            'topdir/foo')
 
435
        self.assertEqual(os.path.realpath('topdir'),
 
436
                         os.path.realpath(tree.basedir))
 
437
        self.assertEqual(os.path.realpath('topdir'),
 
438
                         local_branch_path(branch))
 
439
        self.assertIs(tree.bzrdir, branch.bzrdir)
 
440
        self.assertEqual('foo', relpath)
 
441
        self.make_branch('topdir/foo')
 
442
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
443
            'topdir/foo')
 
444
        self.assertIs(tree, None)
 
445
        self.assertEqual(os.path.realpath('topdir/foo'),
 
446
                         local_branch_path(branch))
 
447
        self.assertEqual('', relpath)
 
448
 
425
449
    def test_open_from_transport(self):
426
450
        # transport pointing at bzrdir should give a bzrdir with root transport
427
451
        # set to the given transport
645
669
        result.open_branch()
646
670
        result.open_repository()
647
671
 
 
672
 
 
673
class TestRemoteSFTP(test_sftp_transport.TestCaseWithSFTPServer):
 
674
 
 
675
    def test_open_containing_tree_or_branch(self):
 
676
        tree = self.make_branch_and_tree('tree')
 
677
        bzrdir.BzrDir.open_containing_tree_or_branch(self.get_url('tree'))