/alpaca

:sweat_drops: Spitting JSON as a microservice

Primary LanguagePythonMIT LicenseMIT

alpaca CircleCI codecov

💦 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

Setting up an endpoint

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 and Content-Type header is application/json.

Clearing endpoints

You should send a POST request to /__clear in order to clear all endpoints.

List endpoints

You should send a GET request to /__list in order to list all saved endpoints.

More docs are coming.


Prerequisites

  • Python 3
  • pipenv

Installing

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.

Contributing

Please feel free for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details