1
# Copyright (C) 2008 Canonical Ltd
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.
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.
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
17
"""Effort tests for the smart protocol."""
24
from bzrlib.branch import Branch
25
from bzrlib.smart import client, server
26
from bzrlib.transport import get_transport
29
class EmptyPushEffortTests(tests.TestCaseWithMemoryTransport):
30
"""Tests that a push of 0 revisions should make a limited number of smart
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)
46
def capture_hpss_call(self, params):
47
self.hpss_calls.append(params.method)
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)
56
'BzrDir.find_repositoryV2',
58
'Branch.last_revision_info',
62
def test_empty_branch_command(self):
63
cmd = builtins.cmd_push()
64
cmd.outf = tests.StringIOWrapper()
66
directory=self.get_url() + 'empty',
67
location=self.smart_server.get_url() + 'target')
68
self.assertTrue(len(self.hpss_calls) <= 8)