Add pytest fixture to allow mocking requests with data file
Roughly, the idea is that http queries are transformed into file queries within http context. If found, the data file is served or not (404). This translates into query response so that the code can actually complete as usual.
For sample use cases, see for examples:
- lister:
- loader-package:
- https://forge.softwareheritage.org/source/swh-loader-core/browse/package-loader/swh/loader/package/tests/test_gnu.py$198
- https://forge.softwareheritage.org/source/swh-loader-core/browse/package-loader/swh/loader/package/tests/test_npm.py$406
- https://forge.softwareheritage.org/source/swh-loader-core/browse/package-loader/swh/loader/package/tests/test_pypi.py$191
- https://forge.softwareheritage.org/source/swh-loader-core/browse/package-loader/swh/loader/package/tests/test_deposit.py$66-67
Note: The fixture's name is not that good, if you have any better idea, now is the time ;)
Test Plan
tox
Migrated from D2082 (view on Phabricator)