~debian-bazaar/debian/sid/bzr-upload/unstable

« back to all changes in this revision

Viewing changes to tests/test_auto_upload_hook.py

  • Committer: Jelmer Vernooij
  • Date: 2019-02-24 00:36:21 UTC
  • Revision ID: jelmer@jelmer.uk-20190224003621-1apocl07m7b8llks
Create transitional package to upgrade to brz, which bundles the
upload plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2011 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
 
import os
18
 
 
19
 
from bzrlib import (
20
 
    tests,
21
 
    )
22
 
 
23
 
from bzrlib.plugins import (
24
 
    upload,
25
 
    )
26
 
from bzrlib.plugins.upload import (
27
 
    cmds,
28
 
    )
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):
38
 
        self.wt = self.make_branch_and_tree('.')
39
 
        self.build_tree(['a'])
40
 
        self.wt.add(['a'])
41
 
        self.wt.commit("one")
42
 
 
43
 
 
44
 
class AutoPushWithLocation(AutoPushHookTests):
45
 
 
46
 
    def setUp(self):
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')
52
 
 
53
 
    def test_auto_push_on_commit(self):
54
 
        self.assertPathDoesNotExist('target')
55
 
        self.build_tree(['b'])
56
 
        self.wt.add(['b'])
57
 
        self.wt.commit("two")
58
 
        self.assertPathExists('target')
59
 
        self.assertPathExists(os.path.join('target', 'a'))
60
 
        self.assertPathExists(os.path.join('target', 'b'))
61
 
 
62
 
    def test_disable_auto_push(self):
63
 
        self.assertPathDoesNotExist('target')
64
 
        self.build_tree(['b'])
65
 
        self.wt.add(['b'])
66
 
        self.wt.commit("two")
67
 
        cmds.set_upload_auto(self.wt.branch, False)
68
 
        self.build_tree(['c'])
69
 
        self.wt.add(['c'])
70
 
        self.wt.commit("three")
71
 
        self.assertPathDoesNotExist(os.path.join('target', 'c'))
72
 
 
73
 
 
74
 
class AutoPushWithoutLocation(AutoPushHookTests):
75
 
 
76
 
    def setUp(self):
77
 
        super(AutoPushWithoutLocation, self).setUp()
78
 
        self.make_start_branch()
79
 
        cmds.set_upload_auto(self.wt.branch, True)
80
 
 
81
 
    def test_dont_push_if_no_location(self):
82
 
        self.assertPathDoesNotExist('target')
83
 
        self.build_tree(['b'])
84
 
        self.wt.add(['b'])
85
 
        self.wt.commit("two")
86
 
        self.assertPathDoesNotExist('target')