/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
1
# Copyright (C) 2008, 2009 Canonical Ltd
0.155.3 by James Westby
Add some tests for the hook, rename the option to "upload_auto"
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
import os
18
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
19
from bzrlib import (
20
    tests,
21
    )
22
0.165.1 by Jelmer Vernooij
Support lazily loading.
23
from bzrlib.plugins import (
24
    upload,
25
    )
26
from bzrlib.plugins.upload import (
27
    cmds,
28
    )
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
29
30
31
class AutoPushHookTests(tests.TestCaseWithTransport):
32
33
    def setUp(self):
34
        super(AutoPushHookTests, self).setUp()
35
        upload.install_auto_upload_hook()
36
37
    def make_start_branch(self):
0.155.3 by James Westby
Add some tests for the hook, rename the option to "upload_auto"
38
        self.wt = self.make_branch_and_tree('.')
39
        self.build_tree(['a'])
40
        self.wt.add(['a'])
41
        self.wt.commit("one")
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
42
43
44
class AutoPushWithLocation(AutoPushHookTests):
45
46
    def setUp(self):
47
        super(AutoPushWithLocation, self).setUp()
48
        self.make_start_branch()
0.165.1 by Jelmer Vernooij
Support lazily loading.
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')
0.155.3 by James Westby
Add some tests for the hook, rename the option to "upload_auto"
52
53
    def test_auto_push_on_commit(self):
54
        self.failIfExists('target')
55
        self.build_tree(['b'])
56
        self.wt.add(['b'])
57
        self.wt.commit("two")
58
        self.failUnlessExists('target')
59
        self.failUnlessExists(os.path.join('target', 'a'))
60
        self.failUnlessExists(os.path.join('target', 'b'))
61
62
    def test_disable_auto_push(self):
63
        self.failIfExists('target')
64
        self.build_tree(['b'])
65
        self.wt.add(['b'])
66
        self.wt.commit("two")
0.165.1 by Jelmer Vernooij
Support lazily loading.
67
        cmds.set_upload_auto(self.wt.branch, False)
0.155.3 by James Westby
Add some tests for the hook, rename the option to "upload_auto"
68
        self.build_tree(['c'])
69
        self.wt.add(['c'])
70
        self.wt.commit("three")
71
        self.failIfExists(os.path.join('target', 'c'))
72
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
73
74
class AutoPushWithoutLocation(AutoPushHookTests):
75
76
    def setUp(self):
77
        super(AutoPushWithoutLocation, self).setUp()
78
        self.make_start_branch()
0.165.1 by Jelmer Vernooij
Support lazily loading.
79
        cmds.set_upload_auto(self.wt.branch, True)
0.152.61 by Vincent Ladeuil
Fix bug #312686 and add an 'upload_auto_quiet' config variable.
80
0.155.3 by James Westby
Add some tests for the hook, rename the option to "upload_auto"
81
    def test_dont_push_if_no_location(self):
82
        self.failIfExists('target')
83
        self.build_tree(['b'])
84
        self.wt.add(['b'])
85
        self.wt.commit("two")
86
        self.failIfExists('target')