This PR adds a test_service service to Baselayer which can be used to mock external API requests during testing. The idea is to tweak configurations for test instances of a Baselayer application (through a test_config.yaml like in SkyPortal, for example) such that external API calls made by the application's handlers are directed to http://localhost:{configs[ports.test_server]} instead of the real API host; the test_service will return mock responses to the Baselayer application. These mock responses are set up and customized by passing to the microservice via configurations the path to a Python module which exposes a make_app() function returning a tornado.web.Application instance. An example such module is provided and configured in the default configs.
This is a precursor to addressing skyportal/skyportal#1792. A follow-up PR will be made to SkyPortal with a more sophisticated test server module to instantiate the microservice with in order to mock external calls within the SkyPortal test suite.
@stefanv Thanks for pointing that out. I'd missed that functionality for detecting services in a skyportal/services directory. I agree that this PR seems overkill now - closing in favor of just a SkyPortal PR.
This PR adds a
test_service
service to Baselayer which can be used to mock external API requests during testing. The idea is to tweak configurations for test instances of a Baselayer application (through atest_config.yaml
like in SkyPortal, for example) such that external API calls made by the application's handlers are directed tohttp://localhost:{configs[ports.test_server]}
instead of the real API host; thetest_service
will return mock responses to the Baselayer application. These mock responses are set up and customized by passing to the microservice via configurations the path to a Python module which exposes amake_app()
function returning atornado.web.Application
instance. An example such module is provided and configured in the default configs.This is a precursor to addressing skyportal/skyportal#1792. A follow-up PR will be made to SkyPortal with a more sophisticated test server module to instantiate the microservice with in order to mock external calls within the SkyPortal test suite.