We originally tried to follow the coding style and conventions of the existing code even if it didn't seem to follow the best practices (no setup and copy'n paste)
However, the common test initialization code has been mode to setUp()
We cannot move add_patch to setUp() because 1) not all the tests must be patched (eg test_download_file_url) and 2) in test_download_file_url_retry_then_success we create a closure over the original object to restore it on second try.
Moreover, the MaaS tests use decorators and it's consistent with the download test.
Note that the MaaS tests should be factorized in the same manner by moving common code to either a function or in a setUp method.
We originally tried to follow the coding style and conventions of the existing code even if it didn't seem to follow the best practices (no setup and copy'n paste)
However, the common test initialization code has been mode to setUp()
We cannot move add_patch to setUp() because 1) not all the tests must be patched (eg test_download_ file_url) and 2) in test_download_ file_url_ retry_then_ success we create a closure over the original object to restore it on second try.
Moreover, the MaaS tests use decorators and it's consistent with the download test.
Note that the MaaS tests should be factorized in the same manner by moving common code to either a function or in a setUp method.