Merge lp:~james-w/pkgme-service/review-click into lp:pkgme-service
Proposed by
James Westby
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | no longer in the source branch. |
Merged at revision: | 146 |
Proposed branch: | lp:~james-w/pkgme-service/review-click |
Merge into: | lp:pkgme-service |
Diff against target: |
122 lines (+54/-11) 2 files modified
src/djpkgme/tasks.py (+15/-4) src/djpkgme/tests/test_tasks.py (+39/-7) |
To merge this branch: | bzr merge lp:~james-w/pkgme-service/review-click |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matias Bordese (community) | Approve | ||
Review via email: mp+191505@code.launchpad.net |
Commit message
Turn the unpacking in to a check that the package is a valid click package.
Description of the change
Hi,
Previously if the unpack failed then there would be an oops and no
results reported to sca. This changes that so that if it fails then
it is reported as not being a valid click package.
Thanks,
James
To post a comment you must log in.
(06:31:50 PM) matiasb: james_w: looks good, just one question, why are the changes in l.93-98 required?
(06:32:16 PM) james_w: hmm
(06:32:23 PM) james_w: I should probably extract that in to a method
(06:32:32 PM) james_w: the code under test does
(06:32:38 PM) james_w: with TempDir() as tempdir:
(06:32:43 PM) james_w: to create a temporary directory
(06:33:06 PM) james_w: and we need to fill that tempdir with stuff as part of mocking the download/extract methods
(06:33:14 PM) james_w: there are two ways we could do this:
(06:33:32 PM) james_w: 1. fill it as a side_effect of the extract mock, exactly like it would be for real
(06:33:55 PM) james_w: but this makes it impossible to assert that the correct path is passed to the download mock
(06:34:05 PM) james_w: (l.105)
(06:34:29 PM) james_w: so I chose 2. mock the TempDir() fixture to return a known directory that is pre-filled with the stuff we need
(06:34:47 PM) james_w: it's so ugly because it's mocking a return from a class that is a content manager that returns itself
(06:34:59 PM) james_w: I couldn't find a nicer way to mock it
(06:35:03 PM) james_w: suggestions welcome
(06:36:19 PM) james_w: (the previous approach to mocking it wasn't working right, as when __enter__ was called on the TempDir object we were setting in the mock, it created a new temporary directory, meaning the files we created then weren't found by the code under test)
(06:36:45 PM) james_w: at the very least I should make that a replace_tempdir method or something to make the intent clearer
(06:37:13 PM) matiasb: hmm... I see, sounds good; no brain for suggestions at this time of the day, with that change, works for me :)