1
# Copyright (C) 2008, 2009, 2011 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
23
from bzrlib.plugins import (
26
from bzrlib.plugins.upload import (
31
class AutoPushHookTests(tests.TestCaseWithTransport):
34
super(AutoPushHookTests, self).setUp()
35
upload.install_auto_upload_hook()
37
def make_start_branch(self):
38
self.wt = self.make_branch_and_tree('.')
39
self.build_tree(['a'])
44
class AutoPushWithLocation(AutoPushHookTests):
47
super(AutoPushWithLocation, self).setUp()
48
self.make_start_branch()
49
cmds.set_upload_auto(self.wt.branch, True)
50
cmds.set_upload_location(self.wt.branch, self.get_url('target'))
51
cmds.set_upload_auto_quiet(self.wt.branch, 'True')
53
def test_auto_push_on_commit(self):
54
self.assertPathDoesNotExist('target')
55
self.build_tree(['b'])
58
self.assertPathExists('target')
59
self.assertPathExists(os.path.join('target', 'a'))
60
self.assertPathExists(os.path.join('target', 'b'))
62
def test_disable_auto_push(self):
63
self.assertPathDoesNotExist('target')
64
self.build_tree(['b'])
67
cmds.set_upload_auto(self.wt.branch, False)
68
self.build_tree(['c'])
70
self.wt.commit("three")
71
self.assertPathDoesNotExist(os.path.join('target', 'c'))
74
class AutoPushWithoutLocation(AutoPushHookTests):
77
super(AutoPushWithoutLocation, self).setUp()
78
self.make_start_branch()
79
cmds.set_upload_auto(self.wt.branch, True)
81
def test_dont_push_if_no_location(self):
82
self.assertPathDoesNotExist('target')
83
self.build_tree(['b'])
86
self.assertPathDoesNotExist('target')