~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_break_lock.py

  • Committer: Robert Collins
  • Date: 2006-04-28 05:54:33 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060428055433-be86bc92d5efd816
Document what the break-lock commands should be like

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.bzrdir import BzrDir
23
 
from bzrlib.tests import TestCaseInTempDir
24
 
 
25
 
class TestBreakLock(TestCaseInTempDir):
 
23
from bzrlib.tests.blackbox import ExternalBase
 
24
 
 
25
 
 
26
class TestBreakLock(ExternalBase):
 
27
 
 
28
    # General principal for break-lock: All the elements that might be locked
 
29
    # by a bzr operation on PATH, are candidates that break-lock may unlock.
 
30
    # so pathologically if we have a lightweight checkout A, of branch B, which
 
31
    # is bound to location C, the following things should be checked for locks
 
32
    # to break:
 
33
    # wt = WorkingTree(A)
 
34
    # wt.branch
 
35
    # wt.branch.repository
 
36
    # wt.branch.get_master_branch()
 
37
    # wt.branch.get_master_branch().repository
 
38
    # so for smoke tests all we need is a bound branch with a checkout of that
 
39
    # and we can then use different urls to test individual cases, for as much
 
40
    # granularity as needed.
 
41
 
 
42
    def setUp(self):
 
43
        super(TestBreakLock, self).setUp()
 
44
        self.build_tree(
 
45
            ['master-repo/',
 
46
             'master-repo/master-branch/',
 
47
             'repo/',
 
48
             'repo/branch/',
 
49
             'checkout/'])
 
50
        bzrlib.bzrdir.BzrDir.create('master-repo').create_repository()
 
51
        self.master_branch = bzrlib.bzrdir.create_branch_convenience(
 
52
            'master-repo/master-branch')
 
53
        bzrlib.bzrdir.BzrDir.create('repo').create_repository()
 
54
        bzrlib.bzrdir.create_branch_convenience('repo/branch')
 
55
        local_branch = bzrlib.bzrdir.create_branch_convenience('repo/branch')
 
56
        local_branch.bind(self.master_branch)
 
57
        checkoutdir = bzrlib.bzrdir.BzrDir.create('checkout')
 
58
        bzrlib.branch.BranchReferenceFormat().initialize(
 
59
            checkoutdir, local_branch)
 
60
        self.wt = bzrlib.workingtree.WorkingTree.open('checkout')
 
61
 
26
62
    def test_break_lock_help(self):
27
 
        self.run_bzr('break-lock', '--help')
28
 
        # shouldn't fail
29
 
 
30
 
    def test_show_no_lock(self):
31
 
        wt = BzrDir.create_standalone_workingtree('.')
32
 
        # out, err = self.run_bzr('break-lock', '--show', '.', retcode=3)
33
 
        # shouldn't see any information
34
 
        # self.assertContainsRe(err, 'not locked')
 
63
        out, err = self.run_bzr('break-lock', '--help')
 
64
        # shouldn't fail and should not produce error output
 
65
        self.assertEqual('', err)
 
66
 
 
67
    def test_break_lock_everything_locked(self):
 
68
        ### if everything is locked, we should be able to unlock the lot.
 
69
        # sketch of test:
 
70
        # setup a ui factory with precanned answers to the 'should I break lock
 
71
        # tests' 
 
72
        bzrlib.ui.ui_factory = ...
 
73
        # lock the lot:
 
74
        self.wt.lock_write()
 
75
        self.master_branch.lock_write()
 
76
        # run the break-lock
 
77
        self.run_bzr('break-lock', 'checkout')
 
78
        # restore (in a finally) the ui
 
79
        bzrlib.ui.ui_factory = originalfactory
 
80
 
 
81
        etc.