Merge lp:~frankban/juju-quickstart/prepare-new-release into lp:juju-quickstart
- prepare-new-release
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 54 |
Proposed branch: | lp:~frankban/juju-quickstart/prepare-new-release |
Merge into: | lp:juju-quickstart |
Diff against target: |
354 lines (+96/-71) 9 files modified
HACKING.rst (+5/-0) quickstart/__init__.py (+2/-2) quickstart/app.py (+22/-2) quickstart/manage.py (+2/-11) quickstart/settings.py (+3/-3) quickstart/tests/test_app.py (+52/-5) quickstart/tests/test_manage.py (+8/-14) quickstart/tests/test_utils.py (+1/-24) quickstart/utils.py (+1/-10) |
To merge this branch: | bzr merge lp:~frankban/juju-quickstart/prepare-new-release |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email: mp+207145@code.launchpad.net |
Commit message
Description of the change
Minor changes in preparation for release.
Bump version up to 1.1.0.
Re-organize the "requires sudo" code.
Restore 100% unit test coverage (compulsive mode on).
Update license headers of modified files.
Tests: `make check`
QA: use quickstart as usual, bootstrapping
both ec2 and local environments.
Francesco Banconi (frankban) wrote : | # |
Richard Harding (rharding) wrote : | # |
LGTM with the one note on potential room for a docs update.
Will QA.
https:/
File quickstart/
https:/
quickstart/
app.bootstrap_
yay for functions that can be tested in isolation.
https:/
File quickstart/
https:/
quickstart/
'raring', 'saucy', 'trusty')
good call, are these tweaks needed to keep it up to date noted? Maybe a
releases section in the hacking doc can note to check the latest charm
version and such?
Richard Harding (rharding) wrote : | # |
- 55. By Francesco Banconi
-
Changes as per review.
Francesco Banconi (frankban) wrote : | # |
*** Submitted:
Minor changes in preparation for release.
Bump version up to 1.1.0.
Re-organize the "requires sudo" code.
Restore 100% unit test coverage (compulsive mode on).
Update license headers of modified files.
Tests: `make check`
QA: use quickstart as usual, bootstrapping
both ec2 and local environments.
R=rharding
CC=
https:/
https:/
File quickstart/
https:/
quickstart/
'raring', 'saucy', 'trusty')
On 2014/02/19 13:29:09, rharding wrote:
> good call, are these tweaks needed to keep it up to date noted? Maybe
a releases
> section in the hacking doc can note to check the latest charm version
and such?
Done.
Francesco Banconi (frankban) wrote : | # |
Thank you!
Preview Diff
1 | === modified file 'HACKING.rst' | |||
2 | --- HACKING.rst 2014-01-30 12:26:02 +0000 | |||
3 | +++ HACKING.rst 2014-02-19 13:55:43 +0000 | |||
4 | @@ -134,6 +134,11 @@ | |||
5 | 134 | precise to saucy), or in the Juju Quickstart Beta PPA: see | 134 | precise to saucy), or in the Juju Quickstart Beta PPA: see |
6 | 135 | <https://launchpad.net/~juju-gui/+archive/quickstart-beta/+packages>. | 135 | <https://launchpad.net/~juju-gui/+archive/quickstart-beta/+packages>. |
7 | 136 | 136 | ||
8 | 137 | Please also keep up to date the possible values for the environments.yaml | ||
9 | 138 | default-series field (see ``quickstart.settings.JUJU_DEFAULT_SERIES``) and the | ||
10 | 139 | set of series supported by the Juju GUI charm | ||
11 | 140 | (see ``quickstart.settings.JUJU_GUI_SUPPORTED_SERIES``). | ||
12 | 141 | |||
13 | 137 | Debugging bundle support | 142 | Debugging bundle support |
14 | 138 | ~~~~~~~~~~~~~~~~~~~~~~~~ | 143 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
15 | 139 | 144 | ||
16 | 140 | 145 | ||
17 | === modified file 'quickstart/__init__.py' | |||
18 | --- quickstart/__init__.py 2014-01-14 09:28:17 +0000 | |||
19 | +++ quickstart/__init__.py 2014-02-19 13:55:43 +0000 | |||
20 | @@ -1,6 +1,6 @@ | |||
21 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
22 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
24 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
25 | 4 | # | 4 | # |
26 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
27 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
28 | @@ -22,7 +22,7 @@ | |||
29 | 22 | from __future__ import unicode_literals | 22 | from __future__ import unicode_literals |
30 | 23 | 23 | ||
31 | 24 | 24 | ||
33 | 25 | VERSION = (1, 0, 0) | 25 | VERSION = (1, 1, 0) |
34 | 26 | 26 | ||
35 | 27 | 27 | ||
36 | 28 | def get_version(): | 28 | def get_version(): |
37 | 29 | 29 | ||
38 | === modified file 'quickstart/app.py' | |||
39 | --- quickstart/app.py 2014-01-31 21:00:06 +0000 | |||
40 | +++ quickstart/app.py 2014-02-19 13:55:43 +0000 | |||
41 | @@ -1,6 +1,6 @@ | |||
42 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
43 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
45 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
46 | 4 | # | 4 | # |
47 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
48 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
49 | @@ -216,6 +216,27 @@ | |||
50 | 216 | print('a new ssh key was generated in {}'.format(key_file)) | 216 | print('a new ssh key was generated in {}'.format(key_file)) |
51 | 217 | 217 | ||
52 | 218 | 218 | ||
53 | 219 | def bootstrap_requires_sudo(is_local): | ||
54 | 220 | """Return True if "sudo" is required to bootstrap the Juju environment. | ||
55 | 221 | |||
56 | 222 | Return False otherwise. | ||
57 | 223 | Raise a ProgramExit if any error occurs retrieving the Juju version. | ||
58 | 224 | """ | ||
59 | 225 | if not is_local: | ||
60 | 226 | return False | ||
61 | 227 | # If this is a local environment, notify the user that "sudo" will be | ||
62 | 228 | # required to bootstrap the application, even in newer Juju versions where | ||
63 | 229 | # "sudo" is invoked by juju-core itself. | ||
64 | 230 | print('sudo privileges required to bootstrap the environment') | ||
65 | 231 | # If the Juju core version is less than 1.17.2 then use sudo for local | ||
66 | 232 | # deployments. | ||
67 | 233 | try: | ||
68 | 234 | major, minor, patch = utils.get_juju_version() | ||
69 | 235 | except ValueError as err: | ||
70 | 236 | raise ProgramExit(bytes(err)) | ||
71 | 237 | return (major, minor, patch) < (1, 17, 2) | ||
72 | 238 | |||
73 | 239 | |||
74 | 219 | def bootstrap(env_name, requires_sudo=False, debug=False): | 240 | def bootstrap(env_name, requires_sudo=False, debug=False): |
75 | 220 | """Bootstrap the Juju environment with the given name. | 241 | """Bootstrap the Juju environment with the given name. |
76 | 221 | 242 | ||
77 | @@ -238,7 +259,6 @@ | |||
78 | 238 | already_bootstrapped = False | 259 | already_bootstrapped = False |
79 | 239 | cmd = ['/usr/bin/juju', 'bootstrap', '-e', env_name] | 260 | cmd = ['/usr/bin/juju', 'bootstrap', '-e', env_name] |
80 | 240 | if requires_sudo: | 261 | if requires_sudo: |
81 | 241 | print('sudo privileges required to bootstrap the environment') | ||
82 | 242 | cmd.insert(0, 'sudo') | 262 | cmd.insert(0, 'sudo') |
83 | 243 | if debug: | 263 | if debug: |
84 | 244 | cmd.append('--debug') | 264 | cmd.append('--debug') |
85 | 245 | 265 | ||
86 | === modified file 'quickstart/manage.py' | |||
87 | --- quickstart/manage.py 2014-01-31 20:51:16 +0000 | |||
88 | +++ quickstart/manage.py 2014-02-19 13:55:43 +0000 | |||
89 | @@ -1,6 +1,6 @@ | |||
90 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
91 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
93 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
94 | 4 | # | 4 | # |
95 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
96 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
97 | @@ -389,16 +389,7 @@ | |||
98 | 389 | print('bootstrapping the {} environment (type: {})'.format( | 389 | print('bootstrapping the {} environment (type: {})'.format( |
99 | 390 | options.env_name, options.env_type)) | 390 | options.env_name, options.env_type)) |
100 | 391 | is_local = options.env_type == 'local' | 391 | is_local = options.env_type == 'local' |
111 | 392 | requires_sudo = False | 392 | requires_sudo = app.bootstrap_requires_sudo(is_local) |
102 | 393 | if is_local: | ||
103 | 394 | # If the Juju core version is less than 1.17.2 then | ||
104 | 395 | # use sudo for local deployments. | ||
105 | 396 | try: | ||
106 | 397 | major, minor, patch = utils.get_juju_version() | ||
107 | 398 | except ValueError as err: | ||
108 | 399 | raise app.ProgramExit(bytes(err)) | ||
109 | 400 | requires_sudo = utils.local_bootstrap_requires_sudo( | ||
110 | 401 | major, minor, patch) | ||
112 | 402 | already_bootstrapped, bsn_series = app.bootstrap( | 393 | already_bootstrapped, bsn_series = app.bootstrap( |
113 | 403 | options.env_name, requires_sudo=requires_sudo, debug=options.debug) | 394 | options.env_name, requires_sudo=requires_sudo, debug=options.debug) |
114 | 404 | 395 | ||
115 | 405 | 396 | ||
116 | === modified file 'quickstart/settings.py' | |||
117 | --- quickstart/settings.py 2013-12-10 17:22:44 +0000 | |||
118 | +++ quickstart/settings.py 2014-02-19 13:55:43 +0000 | |||
119 | @@ -1,6 +1,6 @@ | |||
120 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
121 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
123 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
124 | 4 | # | 4 | # |
125 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
126 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
127 | @@ -26,13 +26,13 @@ | |||
128 | 26 | 26 | ||
129 | 27 | # The default Juju GUI charm URL to use when it is not possible to retrieve it | 27 | # The default Juju GUI charm URL to use when it is not possible to retrieve it |
130 | 28 | # from the charmworld API, e.g. due to temporary connection/charmworld errors. | 28 | # from the charmworld API, e.g. due to temporary connection/charmworld errors. |
132 | 29 | DEFAULT_CHARM_URL = 'cs:precise/juju-gui-80' | 29 | DEFAULT_CHARM_URL = 'cs:precise/juju-gui-83' |
133 | 30 | 30 | ||
134 | 31 | # The quickstart app short description. | 31 | # The quickstart app short description. |
135 | 32 | DESCRIPTION = 'set up a Juju environment (including the GUI) in very few steps' | 32 | DESCRIPTION = 'set up a Juju environment (including the GUI) in very few steps' |
136 | 33 | 33 | ||
137 | 34 | # The possible values for the environments.yaml default-series field. | 34 | # The possible values for the environments.yaml default-series field. |
139 | 35 | JUJU_DEFAULT_SERIES = ('precise', 'quantal', 'raring', 'saucy') | 35 | JUJU_DEFAULT_SERIES = ('precise', 'quantal', 'raring', 'saucy', 'trusty') |
140 | 36 | 36 | ||
141 | 37 | # Retrieve the current juju-core home. | 37 | # Retrieve the current juju-core home. |
142 | 38 | JUJU_HOME = os.getenv('JUJU_HOME', '~/.juju') | 38 | JUJU_HOME = os.getenv('JUJU_HOME', '~/.juju') |
143 | 39 | 39 | ||
144 | === modified file 'quickstart/tests/test_app.py' | |||
145 | --- quickstart/tests/test_app.py 2014-01-31 21:38:59 +0000 | |||
146 | +++ quickstart/tests/test_app.py 2014-02-19 13:55:43 +0000 | |||
147 | @@ -1,6 +1,6 @@ | |||
148 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
149 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
151 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
152 | 4 | # | 4 | # |
153 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
154 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
155 | @@ -400,6 +400,56 @@ | |||
156 | 400 | 400 | ||
157 | 401 | 401 | ||
158 | 402 | @helpers.mock_print | 402 | @helpers.mock_print |
159 | 403 | class TestBootstrapRequiresSudo(ProgramExitTestsMixin, unittest.TestCase): | ||
160 | 404 | |||
161 | 405 | sudo_message = 'sudo privileges required to bootstrap the environment' | ||
162 | 406 | |||
163 | 407 | def patch_get_juju_version(self, return_value): | ||
164 | 408 | """Patch the quickstart.utils.get_juju_version function.""" | ||
165 | 409 | if isinstance(return_value, Exception): | ||
166 | 410 | mock_get_juju_version = mock.Mock(side_effect=return_value) | ||
167 | 411 | else: | ||
168 | 412 | mock_get_juju_version = mock.Mock(return_value=return_value) | ||
169 | 413 | return mock.patch( | ||
170 | 414 | 'quickstart.utils.get_juju_version', mock_get_juju_version) | ||
171 | 415 | |||
172 | 416 | def test_not_local(self, mock_print): | ||
173 | 417 | # Sudo privileges are never required for non-local environments. | ||
174 | 418 | self.assertFalse(app.bootstrap_requires_sudo(False)) | ||
175 | 419 | |||
176 | 420 | def test_sudo_required(self, mock_print): | ||
177 | 421 | # Sudo privileges are required if the Juju version is < 1.17.2. | ||
178 | 422 | versions = [(0, 7, 9), (1, 0, 0), (1, 16, 42), (1, 17, 0), (1, 17, 1)] | ||
179 | 423 | for version in versions: | ||
180 | 424 | with self.patch_get_juju_version(version): | ||
181 | 425 | requires_sudo = app.bootstrap_requires_sudo(True) | ||
182 | 426 | self.assertTrue(requires_sudo, version) | ||
183 | 427 | # On local environments the "sudo privileges required" message is | ||
184 | 428 | # always printed. | ||
185 | 429 | mock_print.assert_called_once_with(self.sudo_message) | ||
186 | 430 | mock_print.reset_mock() | ||
187 | 431 | |||
188 | 432 | def test_sudo_not_required(self, mock_print): | ||
189 | 433 | # Sudo privileges are not required if the Juju version is >= 1.17.2. | ||
190 | 434 | versions = [ | ||
191 | 435 | (1, 17, 2), (1, 17, 10), (1, 18, 0), (1, 18, 2), (2, 16, 1)] | ||
192 | 436 | for version in versions: | ||
193 | 437 | with self.patch_get_juju_version(version): | ||
194 | 438 | requires_sudo = app.bootstrap_requires_sudo(True) | ||
195 | 439 | self.assertFalse(requires_sudo, version) | ||
196 | 440 | # On local environments the "sudo privileges required" message is | ||
197 | 441 | # always printed. | ||
198 | 442 | mock_print.assert_called_once_with(self.sudo_message) | ||
199 | 443 | mock_print.reset_mock() | ||
200 | 444 | |||
201 | 445 | def test_invalid_version(self, mock_print): | ||
202 | 446 | # A ProgramExit is raised if the Juju version is not valid. | ||
203 | 447 | with self.patch_get_juju_version(ValueError(b'bad wolf')): | ||
204 | 448 | with self.assert_program_exit('bad wolf'): | ||
205 | 449 | app.bootstrap_requires_sudo(True) | ||
206 | 450 | |||
207 | 451 | |||
208 | 452 | @helpers.mock_print | ||
209 | 403 | class TestBootstrap( | 453 | class TestBootstrap( |
210 | 404 | helpers.CallTestsMixin, ProgramExitTestsMixin, unittest.TestCase): | 454 | helpers.CallTestsMixin, ProgramExitTestsMixin, unittest.TestCase): |
211 | 405 | 455 | ||
212 | @@ -459,10 +509,7 @@ | |||
213 | 459 | mock_call.assert_has_calls([ | 509 | mock_call.assert_has_calls([ |
214 | 460 | mock.call('sudo', self.juju, 'bootstrap', '-e', self.env_name), | 510 | mock.call('sudo', self.juju, 'bootstrap', '-e', self.env_name), |
215 | 461 | ] + self.make_status_calls(1)) | 511 | ] + self.make_status_calls(1)) |
220 | 462 | mock_print.assert_has_calls([ | 512 | mock_print.assert_called_once_with(self.status_message) |
217 | 463 | mock.call('sudo privileges required to bootstrap the environment'), | ||
218 | 464 | mock.call(self.status_message), | ||
219 | 465 | ]) | ||
221 | 466 | 513 | ||
222 | 467 | def test_success_debug(self, mock_print): | 514 | def test_success_debug(self, mock_print): |
223 | 468 | # The environment is successfully bootstrapped in debug mode. | 515 | # The environment is successfully bootstrapped in debug mode. |
224 | 469 | 516 | ||
225 | === modified file 'quickstart/tests/test_manage.py' | |||
226 | --- quickstart/tests/test_manage.py 2014-01-31 18:09:48 +0000 | |||
227 | +++ quickstart/tests/test_manage.py 2014-02-19 13:55:43 +0000 | |||
228 | @@ -1,6 +1,6 @@ | |||
229 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
230 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
232 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
233 | 4 | # | 4 | # |
234 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
235 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
236 | @@ -669,12 +669,6 @@ | |||
237 | 669 | msg = 'admin-secret not found in {}'.format(path) | 669 | msg = 'admin-secret not found in {}'.format(path) |
238 | 670 | raise ValueError(msg.encode('utf-8')) | 670 | raise ValueError(msg.encode('utf-8')) |
239 | 671 | 671 | ||
240 | 672 | @staticmethod | ||
241 | 673 | def patch_get_juju_version(major, minor, patch): | ||
242 | 674 | """Patch the quickstart.utils.get_juju_version function.""" | ||
243 | 675 | mock_call = mock.Mock(return_value=(major, minor, patch)) | ||
244 | 676 | return mock.patch('quickstart.utils.get_juju_version', mock_call) | ||
245 | 677 | |||
246 | 678 | def test_no_bundle(self, mock_app, mock_open): | 672 | def test_no_bundle(self, mock_app, mock_open): |
247 | 679 | # The application runs correctly if no bundle is provided. | 673 | # The application runs correctly if no bundle is provided. |
248 | 680 | token = 'AUTHTOKEN' | 674 | token = 'AUTHTOKEN' |
249 | @@ -683,12 +677,12 @@ | |||
250 | 683 | mock_app.bootstrap.return_value = (True, 'precise') | 677 | mock_app.bootstrap.return_value = (True, 'precise') |
251 | 684 | mock_app.get_admin_secret = self.mock_get_admin_secret_error | 678 | mock_app.get_admin_secret = self.mock_get_admin_secret_error |
252 | 685 | options = self.make_options() | 679 | options = self.make_options() |
255 | 686 | with self.patch_get_juju_version(1, 17, 1): | 680 | manage.run(options) |
254 | 687 | manage.run(options) | ||
256 | 688 | mock_app.ensure_dependencies.assert_called() | 681 | mock_app.ensure_dependencies.assert_called() |
257 | 689 | mock_app.ensure_ssh_keys.assert_called() | 682 | mock_app.ensure_ssh_keys.assert_called() |
258 | 690 | mock_app.bootstrap.assert_called_once_with( | 683 | mock_app.bootstrap.assert_called_once_with( |
260 | 691 | options.env_name, requires_sudo=False, debug=options.debug) | 684 | options.env_name, requires_sudo=mock_app.bootstrap_requires_sudo(), |
261 | 685 | debug=options.debug) | ||
262 | 692 | mock_app.get_api_url.assert_called_once_with(options.env_name) | 686 | mock_app.get_api_url.assert_called_once_with(options.env_name) |
263 | 693 | mock_app.connect.assert_has_calls([ | 687 | mock_app.connect.assert_has_calls([ |
264 | 694 | mock.call(mock_app.get_api_url(), options.admin_secret), | 688 | mock.call(mock_app.get_api_url(), options.admin_secret), |
265 | @@ -731,9 +725,9 @@ | |||
266 | 731 | # The application correctly handles working with local providers with | 725 | # The application correctly handles working with local providers with |
267 | 732 | # new Juju versions not requiring "sudo" to bootstrap the environment. | 726 | # new Juju versions not requiring "sudo" to bootstrap the environment. |
268 | 733 | options = self.make_options(env_type='local') | 727 | options = self.make_options(env_type='local') |
269 | 728 | mock_app.bootstrap_requires_sudo.return_value = False | ||
270 | 734 | mock_app.bootstrap.return_value = (True, 'precise') | 729 | mock_app.bootstrap.return_value = (True, 'precise') |
273 | 735 | with self.patch_get_juju_version(1, 18, 0): | 730 | manage.run(options) |
272 | 736 | manage.run(options) | ||
274 | 737 | mock_app.bootstrap.assert_called_once_with( | 731 | mock_app.bootstrap.assert_called_once_with( |
275 | 738 | options.env_name, requires_sudo=False, debug=options.debug) | 732 | options.env_name, requires_sudo=False, debug=options.debug) |
276 | 739 | 733 | ||
277 | @@ -741,9 +735,9 @@ | |||
278 | 741 | # The application correctly handles working with local providers when | 735 | # The application correctly handles working with local providers when |
279 | 742 | # Juju requires an external "sudo" call to bootstrap the environment. | 736 | # Juju requires an external "sudo" call to bootstrap the environment. |
280 | 743 | options = self.make_options(env_type='local') | 737 | options = self.make_options(env_type='local') |
281 | 738 | mock_app.bootstrap_requires_sudo.return_value = True | ||
282 | 744 | mock_app.bootstrap.return_value = (True, 'precise') | 739 | mock_app.bootstrap.return_value = (True, 'precise') |
285 | 745 | with self.patch_get_juju_version(1, 17, 1): | 740 | manage.run(options) |
284 | 746 | manage.run(options) | ||
286 | 747 | mock_app.bootstrap.assert_called_once_with( | 741 | mock_app.bootstrap.assert_called_once_with( |
287 | 748 | options.env_name, requires_sudo=True, debug=options.debug) | 742 | options.env_name, requires_sudo=True, debug=options.debug) |
288 | 749 | 743 | ||
289 | 750 | 744 | ||
290 | === modified file 'quickstart/tests/test_utils.py' | |||
291 | --- quickstart/tests/test_utils.py 2014-01-31 18:09:48 +0000 | |||
292 | +++ quickstart/tests/test_utils.py 2014-02-19 13:55:43 +0000 | |||
293 | @@ -1,6 +1,6 @@ | |||
294 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
295 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
297 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
298 | 4 | # | 4 | # |
299 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
300 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
301 | @@ -710,26 +710,3 @@ | |||
302 | 710 | utils.get_juju_version() | 710 | utils.get_juju_version() |
303 | 711 | msg = 'invalid version string: 1.17' | 711 | msg = 'invalid version string: 1.17' |
304 | 712 | self.assertEqual(msg, bytes(context_manager.exception)) | 712 | self.assertEqual(msg, bytes(context_manager.exception)) |
305 | 713 | |||
306 | 714 | |||
307 | 715 | class TestLocalBootstrapRequiresSudo(unittest.TestCase): | ||
308 | 716 | |||
309 | 717 | def test_returns_true_on_lower_than_1_17_2(self): | ||
310 | 718 | # If Juju version is lower than 1.17.2. | ||
311 | 719 | value = utils.local_bootstrap_requires_sudo(1, 17, 0) | ||
312 | 720 | self.assertTrue(value) | ||
313 | 721 | value = utils.local_bootstrap_requires_sudo(1, 16, 5) | ||
314 | 722 | self.assertTrue(value) | ||
315 | 723 | |||
316 | 724 | def test_returns_false_higher_than_1_17_1(self): | ||
317 | 725 | # If juju version is higher than 1.17.1. | ||
318 | 726 | value = utils.local_bootstrap_requires_sudo(1, 17, 2) | ||
319 | 727 | self.assertFalse(value) | ||
320 | 728 | value = utils.local_bootstrap_requires_sudo(1, 17, 10) | ||
321 | 729 | self.assertFalse(value) | ||
322 | 730 | value = utils.local_bootstrap_requires_sudo(1, 18, 0) | ||
323 | 731 | self.assertFalse(value) | ||
324 | 732 | value = utils.local_bootstrap_requires_sudo(1, 18, 2) | ||
325 | 733 | self.assertFalse(value) | ||
326 | 734 | value = utils.local_bootstrap_requires_sudo(2, 16, 1) | ||
327 | 735 | self.assertFalse(value) | ||
328 | 736 | 713 | ||
329 | === modified file 'quickstart/utils.py' | |||
330 | --- quickstart/utils.py 2014-01-31 18:09:48 +0000 | |||
331 | +++ quickstart/utils.py 2014-02-19 13:55:43 +0000 | |||
332 | @@ -1,6 +1,6 @@ | |||
333 | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 | # This file is part of the Juju Quickstart Plugin, which lets users set up a |
334 | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 | # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
336 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
337 | 4 | # | 4 | # |
338 | 5 | # This program is free software: you can redistribute it and/or modify it under | 5 | # This program is free software: you can redistribute it and/or modify it under |
339 | 6 | # the terms of the GNU Affero General Public License version 3, as published by | 6 | # the terms of the GNU Affero General Public License version 3, as published by |
340 | @@ -348,15 +348,6 @@ | |||
341 | 348 | raise ValueError(msg.encode('utf-8')) | 348 | raise ValueError(msg.encode('utf-8')) |
342 | 349 | 349 | ||
343 | 350 | 350 | ||
344 | 351 | def local_bootstrap_requires_sudo(major, minor, patch): | ||
345 | 352 | """Parse Juju version to check if sudo is required for local deployment. | ||
346 | 353 | |||
347 | 354 | Before Juju version 1.17.2 sudo is required for bootstrapping | ||
348 | 355 | local environments. | ||
349 | 356 | """ | ||
350 | 357 | return (major, minor, patch) < (1, 17, 2) | ||
351 | 358 | |||
352 | 359 | |||
353 | 360 | def run_once(function): | 351 | def run_once(function): |
354 | 361 | """Return a decorated version of the given function which runs only once. | 352 | """Return a decorated version of the given function which runs only once. |
355 | 362 | 353 |
Reviewers: mp+207145_ code.launchpad. net,
Message:
Please take a look.
Description:
Minor changes in preparation for release.
Bump version up to 1.1.0.
Re-organize the "requires sudo" code.
Restore 100% unit test coverage (compulsive mode on).
Update license headers of modified files.
Tests: `make check`
QA: use quickstart as usual, bootstrapping
both ec2 and local environments.
https:/ /code.launchpad .net/~frankban/ juju-quickstart /prepare- new-release/ +merge/ 207145
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/65970043/
Affected files (+93, -71 lines): __init_ _.py manage. py settings. py tests/test_ app.py tests/test_ manage. py tests/test_ utils.py
A [revision details]
M quickstart/
M quickstart/app.py
M quickstart/
M quickstart/
M quickstart/
M quickstart/
M quickstart/
M quickstart/utils.py