https://github.com/febrezo/quickmock
A tool for deploying quick HTTP server mocks
https://github.com/febrezo/quickmock
development-workflow http https mock template
Last synced: 3 days ago
JSON representation
A tool for deploying quick HTTP server mocks
- Host: GitHub
- URL: https://github.com/febrezo/quickmock
- Owner: febrezo
- Created: 2019-06-05T11:11:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T13:22:22.000Z (over 6 years ago)
- Last Synced: 2025-09-25T04:53:30.192Z (5 months ago)
- Topics: development-workflow, http, https, mock, template
- Language: Python
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sample Mocked Services
======================
A simple service mocking utility.
Services can be mocked using `.json` files where the paths and the responses can be defined.
Installation
------------
To install the quickmock, just clone the repository and `cd` into it to install it with `pip`.
```
$ git clone http://github.com/febrezo/quickmock
$ cd quickmock
$ pip3 install -e . --user
```
Afterwards, you will be able to use it the tool using the new entry point in your system:
```
$ quickmock --help
```
Simple Service
--------------
A typical `.json` file contains three keywords:
- `host`. The host. Typically, 0.0.0.0 to permit requests from any machine.
- `port`. An integer defining the local port in the Docker container.
- `responses`. This dictionary contains several subdictionaries order by methods and URL.
```
{
"host": "0.0.0.0",
"port": 6000,
"responses": {
"GET": {
"simple/1": [
{
"response": {
"status": 200,
"return": {
"name": "James Bond"
},
"mimetype": "application/json"
}
}
],
"simple/1001": [
{
"response": {
"status": 404,
"return": {
"code": 404,
"message": "User not found"
},
"mimetype": "application/json"
}
}
]
}
}
}
```
More complex examples can be found in the [`./doc/examples`](./doc/examples) folder to define conditional behaviour depending on the headers or data provided together with the request.
However, there is also a creator assistant that guides the user through the creation of a new template:
```
$ quickmock template
```
The output file can be set using `-t`:
```
$ quickmock template -t my_conf.json
```
Deployment
----------
To run the newly created web server, use `quickmock run`:
```
$ quickmock run -c ./my_conf.json
```
For further assistance, use `--help`.