2 Commits

Author SHA1 Message Date
Patrick McCarty b059fb90f3 tests: fix up pycurl mocks
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2019-07-11 13:43:02 -07:00
Patrick McCarty 3f04dd7e5e Implement unified download interface
The download code for licenses, tarballs, and signature files are
similar enough to warrant consolidation into a unified interface, so add
a new function do_curl() that satisfies the needs of all the callers.

Note that I made one change that noticeably changes the output,
hopefully to reduce confusion: The signature download loop no longer
prints error messages, since the end user should not need to care at all
unless a signature cannot be downloaded and verification is required. If
the latter case is true, autospec will still exit and print the fatal
error, so the issue should be straightforward to diagnose after seeing
that error.

A couple of bugs are fixed as a result of using the new function:

  - The FAILONERROR pycurl option is now set for tarball downloads. This
    prevents certain undesirable side-effects like downloading 404
    response pages.

  - Responses from FTP servers are now handled better, since a more
    common "success" code from FTP servers is 226, not 200.

And unit tests have been updated:

  - Added new tests for download.do_curl().

  - Replaced "mock" import with "unittest.mock" for pkg_integrity tests.

  - Revised license and pkg_integrity tests to reflect the new download
    paths.

  - Added missing mocks for the download paths in PyPIVerifier and
    GEMShaVerifier.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2018-12-09 23:08:10 -08:00