Merge lp:~frankban/lpsetup/bug-1034602-handle-target-dir into lp:lpsetup
Status: | Merged |
---|---|
Approved by: | Francesco Banconi |
Approved revision: | 83 |
Merged at revision: | 77 |
Proposed branch: | lp:~frankban/lpsetup/bug-1034602-handle-target-dir |
Merge into: | lp:lpsetup |
Diff against target: |
174 lines (+94/-5) 4 files modified
lpsetup/handlers.py (+27/-2) lpsetup/tests/subcommands/test_smoke.py (+5/-2) lpsetup/tests/test_handlers.py (+57/-0) lpsetup/tests/utils.py (+5/-1) |
To merge this branch: | bzr merge lp:~frankban/lpsetup/bug-1034602-handle-target-dir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Francesco Banconi (community) | Approve | ||
Brad Crittenden (community) | Approve | ||
Review via email: mp+121198@code.launchpad.net |
Commit message
handle_target_dir validates the provided directory.
Description of the change
= Summary =
handle_target_dir (used by update subcommand) should raise an error if the target dir does not exist or is not writable.
== Implementation ==
I decided to also add another validation: handle_target_dir fails if the target dir does not look like a Launchpad branch. This way we can avoid `update` to start, create required directories (eggs, yui etc...), and then crash because `update-sourcecode` can not be found in the target dir.
== Other changes ==
Updated dry run smoke tests to pass a valid target dir to `lp-setup update`.
Added tests for handle_target_dir.
Defined `test_template_dir` at module level in lpsetup.
* typo: does not exist
* It is minor but I'd change "the target dir {0} is not a valid Launchpad branch" to say it is not a valid Launchpad tree. It may be a valid branch but not have a tree associated with it, i.e. devel vs sandbox.
* I think it would be cleaner to move the addCleanup in HandleTargetDir Test.setUp to be done right after the mktemp().
* Your test rely on the supposition that mktemp() will put things in /tmp. It might be more self-documenting and future proof if you extracted the actual directory using os.path.dirname and use that instead.
* The test_exists test is a bit fragile in that other processes could create that same directory after you remove it. Highly unlikely. But, you could avoid the appearance of a problem by using a subdirectory inside temporary directory as something you know does not exist. Picky, for sure.
* In test_is_writable your cleanup is either unnecessary because rmtree doesn't care and removes it anyway or it depends on the chmod cleanup being called before the rmtree cleanup. I just verified it is the former, rmtree does not care about write permissions when removing an owned tree, so the chmod cleanup is unnecessary.
This is a great improvement. Thanks.