~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_effort.py

  • Committer: Andrew Bennetts
  • Date: 2008-09-15 10:02:00 UTC
  • mto: This revision was merged to the branch mainline in revision 3721.
  • Revision ID: andrew.bennetts@canonical.com-20080915100200-0q8xn3n6wmzl2u32
Neater effort tests for push by using a _SmartClient.hooks['call'] hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    tests,
23
23
    )
24
24
from bzrlib.branch import Branch
25
 
from bzrlib.smart import server
 
25
from bzrlib.smart import client, server
26
26
from bzrlib.transport import get_transport
27
27
 
28
28
 
39
39
        self.addCleanup(self.smart_server.tearDown)
40
40
        self.empty_branch = self.make_branch('empty')
41
41
        self.make_branch('target')
 
42
        client._SmartClient.hooks.install_named_hook(
 
43
            'call', self.capture_hpss_call, None)
 
44
        self.hpss_calls = []
 
45
 
 
46
    def capture_hpss_call(self, params):
 
47
        self.hpss_calls.append(params.method)
42
48
 
43
49
    def test_empty_branch_api(self):
44
50
        transport = get_transport(self.smart_server.get_url()).clone('target')
45
51
        target = Branch.open_from_transport(transport)
46
52
        self.empty_branch.push(target)
47
 
        log = self._get_log(keep_log_file=True)
48
 
        self.assertTrue(log.count('hpss call') <= 6)
 
53
        self.assertEqual(
 
54
            ['BzrDir.open',
 
55
             'BzrDir.open_branch',
 
56
             'BzrDir.find_repositoryV2',
 
57
             'Branch.lock_write',
 
58
             'Branch.last_revision_info',
 
59
             'Branch.unlock'],
 
60
            self.hpss_calls)
49
61
 
50
62
    def test_empty_branch_command(self):
51
63
        cmd = builtins.cmd_push()
53
65
        cmd.run(
54
66
            directory=self.get_url() + 'empty',
55
67
            location=self.smart_server.get_url() + 'target')
56
 
        log = self._get_log(keep_log_file=True)
57
 
        self.assertTrue(log.count('hpss call') <= 8)
 
68
        self.assertTrue(len(self.hpss_calls) <= 8)
58
69
 
59
70