~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/commands/test_revert.py

  • Committer: Danny van Heumen
  • Date: 2010-03-09 16:38:10 UTC
  • mto: (4634.139.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: danny@dannyvanheumen.nl-20100309163810-ujn8hcx08f75nlf1
Refined test to make use of locking hooks and also validate if lock is truly a checkout-lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    branch,
20
20
    builtins,
21
21
    errors,
 
22
    lock,
22
23
    )
23
24
from bzrlib.tests import transport_util
24
25
 
34
35
 
35
36
        self.start_logging_connections()
36
37
 
 
38
        # make sure that the cwd is the branch
37
39
        os.chdir('local')
38
40
 
 
41
        # install lock hooks to find out about cmd_revert's locking actions
 
42
        locks_acquired = []
 
43
        locks_released = []
 
44
        lock.Lock.hooks.install_named_hook('lock_acquired',
 
45
            locks_acquired.append, None)
 
46
        lock.Lock.hooks.install_named_hook('lock_released',
 
47
            locks_released.append, None)
 
48
 
 
49
        # execute the revert command (There is nothing to actually revert,
 
50
        # but locks are acquired either way.)
39
51
        revert = builtins.cmd_revert()
40
 
        num_before = len(self._lock_actions)
41
52
        revert.run()
42
 
        num_after = len(self._lock_actions)
43
 
 
44
 
        # only expect the working tree to be locked and released, so 2
45
 
        # additional entries.
46
 
        self.assertEquals(num_before+2, num_after)
47
 
 
48
 
#    def test_commit_both_modified(self):
49
 
#        self.master_wt.commit('empty commit on master')
50
 
#        self.start_logging_connections()
51
 
#
52
 
#        commit = builtins.cmd_commit()
53
 
#        # commit do not provide a directory parameter, we have to change dir
54
 
#        # manually
55
 
#        os.chdir('local')
56
 
#        # cmd_commit translates BoundBranchOutOfDate into BzrCommandError
57
 
#        self.assertRaises(errors.BzrCommandError, commit.run,
58
 
#                          message=u'empty commit', unchanged=True)
59
 
#        self.assertEquals(1, len(self.connections))
60
 
#
61
 
#    def test_commit_local(self):
62
 
#        """Commits with --local should not connect to the master!"""
63
 
#        self.start_logging_connections()
64
 
#
65
 
#        commit = builtins.cmd_commit()
66
 
#        # commit do not provide a directory parameter, we have to change dir
67
 
#        # manually
68
 
#        os.chdir('local')
69
 
#        commit.run(message=u'empty commit', unchanged=True, local=True)
70
 
#
71
 
#        #it shouldn't open any connections
72
 
#        self.assertEquals(0, len(self.connections))
 
53
 
 
54
        # make sure that only one lock is acquired and released.
 
55
        self.assertEqual(1, len(locks_acquired))
 
56
        self.assertEqual(1, len(locks_released))
 
57
 
 
58
        # make sure that the nonces are the same, since otherwise
 
59
        # this would not be the same lock.
 
60
        self.assertEqual(locks_acquired[0].details, locks_released[0].details)
 
61
 
 
62
        # make sure that the locks are checkout locks.
 
63
        self.assertEndsWith(locks_acquired[0].lock_url, "/checkout/lock")
 
64
        self.assertEndsWith(locks_released[0].lock_url, "/checkout/lock")
 
65