This project illustrates one way to mock your HTTP(S) service and write integration tests against it. It uses a Man-in-the-Middle reverse proxy to record the HTTP(S) responses and replays them.
The Use Case for this skeleton: You want to write a python client (client/) to simplify the use of an already existing HTTP Api (service/).
The already existing service takes time to deploy and must be mocked to run the integration tests of your python client.
- In one terminal:
make spin_up_service
- In another terminal:
make start_recording
- In another terminal:
make create_test_cases
make inspect_test_cases
make integration_tests
Once the tests are done, you can kill your mock container:
make clean_integration_tests
If you wish to start using this project with a real client that you need to test, you can simply update the host & port of your service inside of the Makefile and the docker-compose.yaml.
The files/fodlers you need to copy:
- mock_service/
- Makefile
- docker-compose.yaml