bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2011, 2016 Canonical Ltd
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
18 |
from breezy import ( |
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
19 |
branch, |
20 |
urlutils, |
|
21 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
from breezy.tests import ( |
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
23 |
script, |
24 |
)
|
|
25 |
||
26 |
||
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
27 |
class TestRememberMixin(object): |
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
28 |
"""--remember and --no-remember set locations or not.""" |
29 |
||
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
30 |
# the command to run (expecting additional arguments from the tests
|
31 |
command = [] |
|
32 |
# the dir where the command should be run (it should contain a branch for
|
|
33 |
# which the tested locations are/will be set)
|
|
34 |
working_dir = None |
|
35 |
# argument list for the first command invocation
|
|
36 |
first_use_args = [] |
|
37 |
# argument list for the next command invocation
|
|
38 |
next_uses_args = [] |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
39 |
|
40 |
def do_command(self, *args): |
|
41 |
# We always expect the same result here and care only about the
|
|
42 |
# arguments used and their consequences on the remembered locations
|
|
43 |
out, err = self.run_bzr(self.command + list(args), |
|
44 |
working_dir=self.working_dir) |
|
45 |
||
46 |
def test_first_use_no_option(self): |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
47 |
self.do_command(*self.first_use_args) |
48 |
self.assertLocations(self.first_use_args) |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
49 |
|
50 |
def test_first_use_remember(self): |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
51 |
self.do_command('--remember', *self.first_use_args) |
52 |
self.assertLocations(self.first_use_args) |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
53 |
|
54 |
def test_first_use_no_remember(self): |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
55 |
self.do_command('--no-remember', *self.first_use_args) |
56 |
self.assertLocations([]) |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
57 |
|
58 |
def test_next_uses_no_option(self): |
|
59 |
self.setup_next_uses() |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
60 |
self.do_command(*self.next_uses_args) |
61 |
self.assertLocations(self.first_use_args) |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
62 |
|
63 |
def test_next_uses_remember(self): |
|
64 |
self.setup_next_uses() |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
65 |
self.do_command('--remember', *self.next_uses_args) |
66 |
self.assertLocations(self.next_uses_args) |
|
|
5861.1.6
by Vincent Ladeuil
Make TestRemember a test class that can be reused for other commands. |
67 |
|
68 |
def test_next_uses_no_remember(self): |
|
69 |
self.setup_next_uses() |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
70 |
self.do_command('--no-remember', *self.next_uses_args) |
71 |
self.assertLocations(self.first_use_args) |
|
72 |
||
73 |
||
74 |
class TestSendRemember(script.TestCaseWithTransportAndScript, |
|
75 |
TestRememberMixin): |
|
76 |
||
77 |
working_dir = 'work' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
78 |
command = ['send', '-o-', ] |
79 |
first_use_args = ['../parent', '../grand_parent', ] |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
80 |
next_uses_args = ['../new_parent', '../new_grand_parent'] |
81 |
||
|
5861.1.8
by Vincent Ladeuil
Use a real setUp for the part that is really common to all tests (it adds a constraint on setup_next_uses, but this seems like a good thing anyway). |
82 |
def setUp(self): |
83 |
super(TestSendRemember, self).setUp() |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
84 |
self.run_script(''' |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
85 |
$ brz init grand_parent
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
86 |
$ cd grand_parent
|
87 |
$ echo grand_parent > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
88 |
$ brz add
|
89 |
$ brz commit -m 'initial commit'
|
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
90 |
$ cd ..
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
91 |
$ brz branch grand_parent parent
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
92 |
$ cd parent
|
93 |
$ echo parent > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
94 |
$ brz commit -m 'parent'
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
95 |
$ cd ..
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
96 |
$ brz branch parent %(working_dir)s |
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
97 |
$ cd %(working_dir)s |
98 |
$ echo %(working_dir)s > file |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
99 |
$ brz commit -m '%(working_dir)s' |
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
100 |
$ cd ..
|
101 |
''' % {'working_dir': self.working_dir}, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
102 |
null_output_matches_anything=True) |
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
103 |
|
104 |
def setup_next_uses(self): |
|
105 |
# Do a first send that remembers the locations
|
|
106 |
self.do_command(*self.first_use_args) |
|
107 |
# Now create some new targets
|
|
108 |
self.run_script(''' |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
109 |
$ brz branch grand_parent new_grand_parent
|
110 |
$ brz branch parent new_parent
|
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
111 |
''', |
112 |
null_output_matches_anything=True) |
|
113 |
||
114 |
def assertLocations(self, expected_locations): |
|
115 |
if not expected_locations: |
|
116 |
expected_submit_branch, expected_public_branch = None, None |
|
117 |
else: |
|
118 |
expected_submit_branch, expected_public_branch = expected_locations |
|
119 |
br, _ = branch.Branch.open_containing(self.working_dir) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
120 |
self.assertEqual(expected_submit_branch, br.get_submit_branch()) |
121 |
self.assertEqual(expected_public_branch, br.get_public_branch()) |
|
|
5861.1.7
by Vincent Ladeuil
Bah, parametrization leads to a far too verbose parameter list, revert to mixin and inheritance. |
122 |
|
|
5861.1.8
by Vincent Ladeuil
Use a real setUp for the part that is really common to all tests (it adds a constraint on setup_next_uses, but this seems like a good thing anyway). |
123 |
|
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
124 |
class TestPushRemember(script.TestCaseWithTransportAndScript, |
125 |
TestRememberMixin): |
|
126 |
||
127 |
working_dir = 'work' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
128 |
command = ['push', ] |
129 |
first_use_args = ['../target', ] |
|
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
130 |
next_uses_args = ['../new_target'] |
131 |
||
132 |
def setUp(self): |
|
133 |
super(TestPushRemember, self).setUp() |
|
134 |
self.run_script(''' |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
135 |
$ brz init %(working_dir)s |
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
136 |
$ cd %(working_dir)s |
137 |
$ echo some content > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
138 |
$ brz add
|
139 |
$ brz commit -m 'initial commit'
|
|
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
140 |
$ cd ..
|
141 |
''' % {'working_dir': self.working_dir}, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
142 |
null_output_matches_anything=True) |
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
143 |
|
144 |
def setup_next_uses(self): |
|
145 |
# Do a first push that remembers the location
|
|
146 |
self.do_command(*self.first_use_args) |
|
147 |
# Now create some new content
|
|
148 |
self.run_script(''' |
|
149 |
$ cd %(working_dir)s |
|
150 |
$ echo new content > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
151 |
$ brz commit -m 'new content'
|
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
152 |
$ cd ..
|
153 |
''' % {'working_dir': self.working_dir}, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
154 |
null_output_matches_anything=True) |
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
155 |
|
156 |
def assertLocations(self, expected_locations): |
|
157 |
br, _ = branch.Branch.open_containing(self.working_dir) |
|
158 |
if not expected_locations: |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
159 |
self.assertEqual(None, br.get_push_location()) |
|
5861.1.9
by Vincent Ladeuil
Fix --no-remember for the first push. |
160 |
else: |
161 |
expected_push_location = expected_locations[0] |
|
162 |
push_location = urlutils.relative_url(br.base, |
|
163 |
br.get_push_location()) |
|
164 |
self.assertIsSameRealPath(expected_push_location, push_location) |
|
165 |
||
166 |
||
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
167 |
class TestPullRemember(script.TestCaseWithTransportAndScript, |
168 |
TestRememberMixin): |
|
169 |
||
170 |
working_dir = 'work' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
171 |
command = ['pull', ] |
172 |
first_use_args = ['../parent', ] |
|
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
173 |
next_uses_args = ['../new_parent'] |
174 |
||
175 |
def setUp(self): |
|
176 |
super(TestPullRemember, self).setUp() |
|
177 |
self.run_script(''' |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
178 |
$ brz init parent
|
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
179 |
$ cd parent
|
180 |
$ echo parent > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
181 |
$ brz add
|
182 |
$ brz commit -m 'initial commit'
|
|
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
183 |
$ cd ..
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
184 |
$ brz init %(working_dir)s |
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
185 |
''' % {'working_dir': self.working_dir}, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
186 |
null_output_matches_anything=True) |
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
187 |
|
188 |
def setup_next_uses(self): |
|
189 |
# Do a first push that remembers the location
|
|
190 |
self.do_command(*self.first_use_args) |
|
191 |
# Now create some new content
|
|
192 |
self.run_script(''' |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
193 |
$ brz branch parent new_parent
|
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
194 |
$ cd new_parent
|
195 |
$ echo new parent > file
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
196 |
$ brz commit -m 'new parent'
|
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
197 |
$ cd ..
|
|
7290.49.1
by Jelmer Vernooij
Fix flake errors. |
198 |
''', null_output_matches_anything=True) |
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
199 |
|
200 |
def assertLocations(self, expected_locations): |
|
201 |
br, _ = branch.Branch.open_containing(self.working_dir) |
|
202 |
if not expected_locations: |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
203 |
self.assertEqual(None, br.get_parent()) |
|
5861.1.10
by Vincent Ladeuil
Fix --no-remember for the first pull. |
204 |
else: |
205 |
expected_pull_location = expected_locations[0] |
|
206 |
pull_location = urlutils.relative_url(br.base, br.get_parent()) |
|
207 |
self.assertIsSameRealPath(expected_pull_location, pull_location) |