~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
                           )
31
31
import bzrlib.repository as repository
32
32
from bzrlib.tests import TestCase, TestCaseWithTransport
 
33
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
33
34
from bzrlib.transport import get_transport
34
35
from bzrlib.transport.http import HttpServer
35
36
from bzrlib.transport.memory import MemoryServer
456
457
        finally:
457
458
            bzrdir.BzrDirFormat.set_default_format(old_format)
458
459
        self.assertFalse(dir.needs_format_conversion())
 
460
 
 
461
 
 
462
class NonLocalTests(TestCaseWithTransport):
 
463
    """Tests for bzrdir static behaviour on non local paths."""
 
464
 
 
465
    def setUp(self):
 
466
        super(NonLocalTests, self).setUp()
 
467
        self.transport_server = MemoryServer
 
468
    
 
469
    def test_create_branch_convenience(self):
 
470
        # outside a repo the default convenience output is a repo+branch_tree
 
471
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
472
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
473
        try:
 
474
            branch = bzrdir.BzrDir.create_branch_convenience(self.get_url('foo'))
 
475
            self.assertRaises(errors.NoWorkingTree,
 
476
                              branch.bzrdir.open_workingtree)
 
477
            branch.bzrdir.open_repository()
 
478
        finally:
 
479
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
480
 
 
481
    def test_create_branch_convenience_force_tree_not_local_fails(self):
 
482
        # outside a repo the default convenience output is a repo+branch_tree
 
483
        old_format = bzrdir.BzrDirFormat.get_default_format()
 
484
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
485
        try:
 
486
            self.assertRaises(errors.NotLocalUrl,
 
487
                bzrdir.BzrDir.create_branch_convenience,
 
488
                self.get_url('foo'),
 
489
                force_new_tree=True)
 
490
            t = get_transport(self.get_url('.'))
 
491
            self.assertFalse(t.has('foo'))
 
492
        finally:
 
493
            bzrdir.BzrDirFormat.set_default_format(old_format)
 
494