cesium-ml / baselayer

Fully customizable (scientific, compute-intensive) web application template
http://cesium-ml.org/baselayer/
31 stars 18 forks source link

Add service for mocking external APIs in testing #210

Closed kmshin1397 closed 3 years ago

kmshin1397 commented 3 years ago

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.

kmshin1397 commented 3 years ago

@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.