/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3703.3.2 by Andrew Bennetts
Simple effort tests for pushing an empty branch.
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 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
43
    def test_empty_branch_api(self):
44
        transport = get_transport(self.smart_server.get_url()).clone('target')
45
        target = Branch.open_from_transport(transport)
46
        self.empty_branch.push(target)
47
        log = self._get_log(keep_log_file=True)
48
        self.assertTrue(log.count('hpss call') <= 6)
49
50
    def test_empty_branch_command(self):
51
        cmd = builtins.cmd_push()
52
        cmd.outf = tests.StringIOWrapper()
53
        cmd.run(
54
            directory=self.get_url() + 'empty',
55
            location=self.smart_server.get_url() + 'target')
56
        log = self._get_log(keep_log_file=True)
57
        self.assertTrue(log.count('hpss call') <= 8)
58
59