Page MenuHomeSoftware Heritage

exceptions: custom error response
ClosedPublic

Authored by DanSeraf on Tue, Mar 10, 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

DanSeraf created this revision.Tue, Mar 10, 12:11 PM

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]

vlorentz requested changes to this revision.Tue, Mar 10, 12:18 PM
This revision now requires changes to proceed.Tue, Mar 10, 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

DanSeraf updated this revision to Diff 9952.Tue, Mar 10, 3:10 PM
assert APIError raises when the payload is too large
live_server override, only one per session
vlorentz accepted this revision.Tue, Mar 10, 7:50 PM
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.Tue, Mar 10, 7:50 PM
DanSeraf added inline comments.Wed, Mar 11, 9:29 AM
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

DanSeraf updated this revision to Diff 9983.Wed, Mar 11, 9:34 AM

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

This revision was automatically updated to reflect the committed changes.