Page MenuHomeSoftware Heritage

exceptions: custom error response
ClosedPublic

Authored by DanSeraf on Mar 10 2020, 12:11 PM.

Details

Summary

Print an error message based on http response (T2300)

Diff Detail

Repository
rDTSCN Code scanner
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Now that swh-scanner has tests, it would be nice if every new feature and bugfix added (or changed) one or more tests.

swh/scanner/exceptions.py
13–15 ↗(On Diff #9942)

nitpick: inconsistent casing, and s/request/requests/

20 ↗(On Diff #9942)

You can probably use resp.reason instead of status_code_msg[resp.status]

This revision now requires changes to proceed.Mar 10 2020, 12:18 PM

Now that swh-scanner has tests, it would be nice if every new feature and bugfix added (or changed) one or more tests.

Yes, i'll write test also on this one

assert APIError raises when the payload is too large
live_server override, only one per session
vlorentz added inline comments.
swh/scanner/tests/conftest.py
63–66 ↗(On Diff #9965)

slightly confusing, but ok.

Maybe a comment?

swh/scanner/tests/test_scanner.py
45 ↗(On Diff #9965)

You can also use the match argument in APIError to check the reason is there, but that's not very important

This revision is now accepted and ready to land.Mar 10 2020, 7:50 PM
swh/scanner/tests/conftest.py
63–66 ↗(On Diff #9965)

there is no need of overriding the live_server so i'll remove the no-start-live-server option in pytest.ini

removed --no-start-live-server option in pytest.ini