💦 Spitting JSON as a microservice
Alpaca is a tool that aims to mock API requests in test enviroments such as CI.
It is available in Docker Hub:
docker run -p 5000:5000 felipemfp/alpaca
You should send a POST request to /__setup/<endpoint>
. For example:
curl \
-d "[{"name": "Foo"}, {"name": "Joe"}]" \
-X POST \
http://localhost:5000/__setup/v2/users?method=GET&status=200&Content-Type=application/json
Now alpaca
will send [{"name": "Foo"}, {"name": "Joe"}]
when /v2/users
is requested:
curl http://localhost:5000/v2/users
The response status code is
200
andContent-Type
header isapplication/json
.
You should send a POST request to /__clear
in order to clear all endpoints.
You should send a GET request to /__list
in order to list all saved endpoints.
More docs are coming.
- Python 3
- pipenv
Once you have the project cloned to your computer, install the dependencies with pipenv:
pipenv install
Activate the virtual environment:
pipenv shell
Run the project:
FLASK_APP=alpaca.py flask run --reload
Now you can try it on http://localhost:5000.
Please feel free for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Felipe Pontes - Initial work - felipemfp
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details