Repository navigation
Remove max_length parameter from fetch - #1519
Conversation
There was a problem hiding this comment.
This breaks FetcherInterface API but the result looks like the API we should have made in the first place: it's a cleaner separation of duties and simplifies the fetcher implementation. LGTM in general.
Is it possible to make a test for the case you are fixing?
It would make sense to add tests for ngclient fetcher: not just the ones that already exist for fetcher in legacy code but for download_bytes() and download_file() -- where testing this issue would make sense |
b821f3c to
1846291
Compare
|
Added some tests, mostly copied from test_fetcher.py but modified for the implementation. There's some duplication, maybe unneeded ... |
What do you mean specifically -- this PR seems to test the complete RequestsFetcher surface? Obviously more tests doesn't hurt but it looks like coverage wise we're ok. |
We still miss tests for |
|
That's what I could do with the available test utils: 0f19815 |
jku
left a comment
There was a problem hiding this comment.
This looks fine otherwise but I refuse to accept a test that takes 5 seconds to run. I can accept either not testing slow retrieval here or making the test runtime more reasonable
|
Actually I do have a question: is it necessary to setup and teardown the server for each individual test? |
Hmm ... no, I don't think so ... let me fix it. |
I was kind of expecting it 😁 I'll remove the test and open an issue so that we do it properly (maybe tweak the current Edit: my mistake, the timeout is a socket parameter, so tweak the socket timeouts: #1552 |
If a file has a bigger size than expected, RequestFetcher.fetch downloads it up to max_length without any errors. Only the consecutive hash check raises exception. A better behaviour in such case would be to raise a DownloadLengthMismatchError. For this reason this commit: - removes max_length from the fetch() definition, - modifies download_file to check the downloaded length after each chunk and raise an error accordingly. Signed-off-by: Teodora Sechkova <[email protected]>
Add tests for the file/data download. Signed-off-by: Teodora Sechkova <[email protected]>
0f19815 to
35ef056
Compare
|
So test commits are squashed in a single one 35ef056:
I think the test setup can be further improved since the temp data file can be created once per class too but currently |
Fixes #1502
Description of the changes being introduced by the pull request:
If a file has a bigger size than expected, RequestFetcher.fetch
downloads it up to max_length without any errors. Only the
consecutive hash check raises exception. A better behavior
in such case would be to raise a DownloadLengthMismatchError.
For this reason this PR:
each chunk and raise an error accordingly.
Please verify and check that the pull request fulfills the following
requirements: