https://codereview.appspot.com/132770043/diff/60001/quickstart/utils.py#newcode360
quickstart/utils.py:360: try:
Uhm... What if the ValueError is due to the int conversion?
Do we need to retry the same int conversion twice?
What do you think about something like:
parts = version_string.split('.', 2)
if len(parts) == 2: parts.append(0)
try:
major, minor, patch = map(int, parts)
...
Very nice branch Jay.
I have some other minor suggestions, and I am well over my EOD, so I'll
QA this on Monday.
Thank you!
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ platform_ support. py platform_ support. py (right):
File quickstart/
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ platform_ support. py#newcode26 platform_ support. py:26: import platform
quickstart/
Pre-existing, by could you please add a new line here separating stdlib
imports from quickstart ones?
The latter must also be put in alphabetical order.
from quickstart import (
settings,
utils,
)
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ platform_ support. py#newcode117 platform_ support. py:117: Also return a flag indicating
quickstart/
whetehr the user requested to customize
Typo: whetehr.
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ platform_ support. py#newcode130 platform_ support. py:130: if juju_command != "" and legacy. python. org/dev/ peps/pep- 0008/#id41
quickstart/
juju_command != platform_command:
"if juju_command:" is sufficient here, an empty string evaluates to
False.
See PEP8: http://
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ app.py tests/test_ app.py (right):
File quickstart/
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ app.py# newcode1646 tests/test_ app.py: 1646: class o(unittest. TestCase) : sSudo?
quickstart/
TestRequiresSud
TestJujuRequire
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ app.py# newcode1659 tests/test_ app.py: 1659: (app.juju_ requires_ sudo('local' , version, False))
quickstart/
self.assertTrue
We could pass the version as second argument to assertTrue here, so
that, in case of failure, we know what version failed:
self.assertTrue( juju_requires_ sudo('local' , version, False),
app.
version)
Or similar.
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ app.py# newcode1664 tests/test_ app.py: 1664: e(app.juju_ requires_ sudo('local' , version, False))
quickstart/
self.assertFals
Ditto.
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ app.py# newcode1668 tests/test_ app.py: 1668: with es(app. ProgramExit) : sMixin, which lets you easily ensure
quickstart/
self.assertRais
test_app defines a ProgramExitTest
that the exit message is also correct, e.g.:
with self.assert_ program_ exit('bad wolf'): juju_requires_ sudo('local' , version, True)
app.
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ platform_ support. py tests/test_ platform_ support. py (right):
File quickstart/
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ tests/test_ platform_ support. py#newcode178 tests/test_ platform_ support. py:178: def fails_when_ ignore_ env_var( self):
quickstart/
test_getenv_
This test seems no longer valid, and we need to add a test for the case
JUJU is set to the default command (customized should be false).
Also, expected is starting to be a little be vague on those tests.
I'd read them better, for example, like:
expected_command = '/custom/juju' 'os.environ' , {'JUJU': expected_command}): support. get_juju_ command( None) ls(expected_ command, command) (customized)
with mock.patch(
command, customized = platform_
self.assertEqua
self.assertTrue
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ utils.py
File quickstart/utils.py (right):
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ utils.py# newcode347 utils.py: 347: Handles the special case of no patch level by
quickstart/
defaulting to 0.
Since the other parts of the docstring use imperative, I'd do the same
here: s/Handles/Handle/.
https:/ /codereview. appspot. com/132770043/ diff/60001/ quickstart/ utils.py# newcode360 utils.py: 360: try: string. split(' .', 2)
parts. append( 0)
quickstart/
Uhm... What if the ValueError is due to the int conversion?
Do we need to retry the same int conversion twice?
What do you think about something like:
parts = version_
if len(parts) == 2:
try:
major, minor, patch = map(int, parts)
...
https:/ /codereview. appspot. com/132770043/