/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_effort.py

  • Committer: Andrew Bennetts
  • Date: 2008-09-22 04:48:47 UTC
  • mfrom: (3719 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3721.
  • Revision ID: andrew.bennetts@canonical.com-20080922044847-ad1y8ibge3s2ak4i
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Effort tests for the smart protocol."""
 
18
 
 
19
from bzrlib import (
 
20
    builtins,
 
21
    debug,
 
22
    tests,
 
23
    )
 
24
from bzrlib.branch import Branch
 
25
from bzrlib.smart import client, server
 
26
from bzrlib.transport import get_transport
 
27
 
 
28
 
 
29
class EmptyPushEffortTests(tests.TestCaseWithMemoryTransport):
 
30
    """Tests that a push of 0 revisions should make a limited number of smart
 
31
    protocol RPCs.
 
32
    """
 
33
 
 
34
    def setUp(self):
 
35
        super(EmptyPushEffortTests, self).setUp()
 
36
        debug.debug_flags.add('hpss')
 
37
        self.smart_server = server.SmartTCPServer_for_testing()
 
38
        self.smart_server.setUp(self.get_server())
 
39
        self.addCleanup(self.smart_server.tearDown)
 
40
        self.empty_branch = self.make_branch('empty')
 
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)
 
48
 
 
49
    def test_empty_branch_api(self):
 
50
        transport = get_transport(self.smart_server.get_url()).clone('target')
 
51
        target = Branch.open_from_transport(transport)
 
52
        self.empty_branch.push(target)
 
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)
 
61
 
 
62
    def test_empty_branch_command(self):
 
63
        cmd = builtins.cmd_push()
 
64
        cmd.outf = tests.StringIOWrapper()
 
65
        cmd.run(
 
66
            directory=self.get_url() + 'empty',
 
67
            location=self.smart_server.get_url() + 'target')
 
68
        self.assertTrue(len(self.hpss_calls) <= 8)
 
69
 
 
70