# PyMock-API
[![PyPI](https://img.shields.io/pypi/v/PyMock-API?color=%23099cec&label=PyPI&logo=pypi&logoColor=white)](https://pypi.org/project/PyMock-API)
[![Release](https://img.shields.io/github/release/Chisanan232/PyMock-API.svg?label=Release&logo=github)](https://github.com/Chisanan232/PyMock-API/releases)
[![CI](https://github.com/Chisanan232/PyMock-API/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/Chisanan232/PyMock-API/actions/workflows/ci-cd.yml)
[![codecov](https://codecov.io/gh/Chisanan232/PyMock-API/graph/badge.svg?token=r5HJxg9KhN)](https://codecov.io/gh/Chisanan232/PyMock-API)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Chisanan232/PyMock-API/master.svg)](https://results.pre-commit.ci/latest/github/Chisanan232/PyMock-API/master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chisanan232_PyMock-API&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chisanan232_PyMock-API)
[![documentation](https://github.com/Chisanan232/PyMock-API/actions/workflows/documentation.yaml/badge.svg)](https://chisanan232.github.io/PyMock-API/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
A Python tool to mock API easily and humanly without any coding.
[Overview](#overview) | [Python versions support](#Python-versions-support) | [Quickly Start](#quickly-start) | [Documentation](#documentation)
<hr>
## Overview
Do you ever have experience about needing to set up a very simple application and write some APIs with hardcode response again and again
for developing Font-End site? **_PyMock-API_** provides a command line tool to let developers could quickly and easily set up application
to mock APIs with configuration only.
## Python versions support
The code base of **_PyMock-API_** to set up an application still depends on third party Python package, i.e., **_Flask_**, **_FastAPI_**,
etc. So the Python versions it supports also be affected by them, e.g., **_Flask_** only supports Python version 3.8 up currently. So
**_PyMock-API_** also only supports version Python 3.8 up.
[![Supported Versions](https://img.shields.io/pypi/pyversions/PyMock-API.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/PyMock-API)
## Quickly Start
Here section would lead you quickly start to set up your first one application by **_PyMock-API_** for mocking APIs easily.
In basically, it has 3 steps: install the package, configure settings about the APIs for mocking and run command.
* [Install](#install-command-line-tool)
* [Configure](#configure-setting-to-mock-target-apis)
* [Run](#run-command-to-set-up-application)
### Install command line tool
First of all, we need to install the command line tool and the way to install is same as installing Python package by ``pip``.
```console
>>> pip install pymock-api
```
If the runtime environment has installed some Python web framework, e.g., **_Flask_**, you also could install **_Pymock-API_**
with one specific option as following:
```console
>>> pip install "pymock-api[flask]"
```
Then it would only install the lowest Python dependencies you need.
After you done above step, please make sure the command line tool feature should work finely by below command:
```console
>>> mock-api --help
```
> **Note**
>
> Please take a look at option _--app-type_ (this option is in subcommand **_mock-api run_**) of the command line tool. Its option
> value could be ``auto``, ``flask`` or ``fastapi``. It means that **_PyMock-API_** only supports 2 Python web frameworks: **_Flask_**
> and **_FastAPI_**.
### Configure setting to mock target APIs
Now, we have the command line tool. Let's configure the settings it needs to set up application to mock API.
The configuration format of **_PyMock-API_** to use is **YAML**. So let's write below settings in YAML file:
```yaml
mocked_apis:
google_home:
url: '/google'
http:
request:
method: 'GET'
response:
strategy: string
value: 'This is Google home API.'
```
### Run command to set up application
Now, both of the command line tool and configuration have been already. So let's try to run the command to set up application!
```console
>>> mock-api run -c <your configuration path>
```
You would see some log messages in terminal and that is the log of web server by one specific Python web framework.
And you could test the API by ``curl``:
```console
>>> curl http://127.0.0.1:9672/google
"This is Google home API."%
```
![demonstration](./docs/images/demonstration_pymock-api_cli.gif)
## Documentation
Currently, it won't have documentation. But it would have soon.
## Coding style and following rules
**_PyMock-API_** follows coding styles **_black_** and **_PyLint_** to control code quality.
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)
## Downloading state
**_PyMock-API_** still a young open source which keep growing. Here's its download state:
[![Downloads](https://pepy.tech/badge/PyMock-API)](https://pepy.tech/project/PyMock-API)
[![Downloads](https://pepy.tech/badge/PyMock-API/month)](https://pepy.tech/project/PyMock-API)
## License
[MIT License](./LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/Chisanan232/PyMock-API",
"name": "PyMock-API",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "mock, API, mock API, web, server",
"author": "Liu, Bryant",
"author_email": "chi10211201@cycu.org.tw",
"download_url": "https://files.pythonhosted.org/packages/63/1b/73346e2e3649547e10c7ca55b9d04991ab81b01b430e9d6c0045c42bb3f6/pymock_api-0.1.0.tar.gz",
"platform": null,
"description": "# PyMock-API\n\n[![PyPI](https://img.shields.io/pypi/v/PyMock-API?color=%23099cec&label=PyPI&logo=pypi&logoColor=white)](https://pypi.org/project/PyMock-API)\n[![Release](https://img.shields.io/github/release/Chisanan232/PyMock-API.svg?label=Release&logo=github)](https://github.com/Chisanan232/PyMock-API/releases)\n[![CI](https://github.com/Chisanan232/PyMock-API/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/Chisanan232/PyMock-API/actions/workflows/ci-cd.yml)\n[![codecov](https://codecov.io/gh/Chisanan232/PyMock-API/graph/badge.svg?token=r5HJxg9KhN)](https://codecov.io/gh/Chisanan232/PyMock-API)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Chisanan232/PyMock-API/master.svg)](https://results.pre-commit.ci/latest/github/Chisanan232/PyMock-API/master)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Chisanan232_PyMock-API&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Chisanan232_PyMock-API)\n[![documentation](https://github.com/Chisanan232/PyMock-API/actions/workflows/documentation.yaml/badge.svg)](https://chisanan232.github.io/PyMock-API/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Python tool to mock API easily and humanly without any coding.\n\n[Overview](#overview) | [Python versions support](#Python-versions-support) | [Quickly Start](#quickly-start) | [Documentation](#documentation)\n<hr>\n\n\n## Overview\n\nDo you ever have experience about needing to set up a very simple application and write some APIs with hardcode response again and again\nfor developing Font-End site? **_PyMock-API_** provides a command line tool to let developers could quickly and easily set up application\nto mock APIs with configuration only.\n\n\n## Python versions support\n\nThe code base of **_PyMock-API_** to set up an application still depends on third party Python package, i.e., **_Flask_**, **_FastAPI_**,\netc. So the Python versions it supports also be affected by them, e.g., **_Flask_** only supports Python version 3.8 up currently. So\n**_PyMock-API_** also only supports version Python 3.8 up.\n\n[![Supported Versions](https://img.shields.io/pypi/pyversions/PyMock-API.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/PyMock-API)\n\n\n## Quickly Start\n\nHere section would lead you quickly start to set up your first one application by **_PyMock-API_** for mocking APIs easily.\n\nIn basically, it has 3 steps: install the package, configure settings about the APIs for mocking and run command.\n\n* [Install](#install-command-line-tool)\n* [Configure](#configure-setting-to-mock-target-apis)\n* [Run](#run-command-to-set-up-application)\n\n### Install command line tool\n\nFirst of all, we need to install the command line tool and the way to install is same as installing Python package by ``pip``.\n\n```console\n>>> pip install pymock-api\n```\n\nIf the runtime environment has installed some Python web framework, e.g., **_Flask_**, you also could install **_Pymock-API_**\nwith one specific option as following:\n\n```console\n>>> pip install \"pymock-api[flask]\"\n```\n\nThen it would only install the lowest Python dependencies you need.\n\nAfter you done above step, please make sure the command line tool feature should work finely by below command:\n\n```console\n>>> mock-api --help\n```\n\n> **Note**\n>\n> Please take a look at option _--app-type_ (this option is in subcommand **_mock-api run_**) of the command line tool. Its option\n> value could be ``auto``, ``flask`` or ``fastapi``. It means that **_PyMock-API_** only supports 2 Python web frameworks: **_Flask_**\n> and **_FastAPI_**.\n\n### Configure setting to mock target APIs\n\nNow, we have the command line tool. Let's configure the settings it needs to set up application to mock API.\n\nThe configuration format of **_PyMock-API_** to use is **YAML**. So let's write below settings in YAML file:\n\n```yaml\nmocked_apis:\n google_home:\n url: '/google'\n http:\n request:\n method: 'GET'\n response:\n strategy: string\n value: 'This is Google home API.'\n```\n\n### Run command to set up application\n\nNow, both of the command line tool and configuration have been already. So let's try to run the command to set up application!\n\n```console\n>>> mock-api run -c <your configuration path>\n```\n\nYou would see some log messages in terminal and that is the log of web server by one specific Python web framework.\n\nAnd you could test the API by ``curl``:\n\n```console\n>>> curl http://127.0.0.1:9672/google\n\"This is Google home API.\"%\n```\n\n![demonstration](./docs/images/demonstration_pymock-api_cli.gif)\n\n## Documentation\n\nCurrently, it won't have documentation. But it would have soon.\n\n\n## Coding style and following rules\n\n**_PyMock-API_** follows coding styles **_black_** and **_PyLint_** to control code quality.\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)\n\n\n## Downloading state\n\n**_PyMock-API_** still a young open source which keep growing. Here's its download state:\n\n[![Downloads](https://pepy.tech/badge/PyMock-API)](https://pepy.tech/project/PyMock-API)\n[![Downloads](https://pepy.tech/badge/PyMock-API/month)](https://pepy.tech/project/PyMock-API)\n\n\n## License\n\n[MIT License](./LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\ud83d\udd78\ud83e\udd16\ud83d\udc7a A Python tool to mock API easily and humanly without any coding.",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://chisanan232.github.io/PyMock-API/",
"Homepage": "https://github.com/Chisanan232/PyMock-API"
},
"split_keywords": [
"mock",
" api",
" mock api",
" web",
" server"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ee5cf5d287eed9303680d43052dca88636f5cbe97480c7864362e0ea223a418",
"md5": "3e1a47c98cfe19d7b9aa84a7554b8bd9",
"sha256": "b3acdba71c8a970f2a2d654bd80a2c5916b428bde8448cc663f3c7724afa8410"
},
"downloads": -1,
"filename": "pymock_api-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e1a47c98cfe19d7b9aa84a7554b8bd9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 75839,
"upload_time": "2024-03-26T04:09:50",
"upload_time_iso_8601": "2024-03-26T04:09:50.646191Z",
"url": "https://files.pythonhosted.org/packages/4e/e5/cf5d287eed9303680d43052dca88636f5cbe97480c7864362e0ea223a418/pymock_api-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "631b73346e2e3649547e10c7ca55b9d04991ab81b01b430e9d6c0045c42bb3f6",
"md5": "aba4a09d7dfdb05f0afc86e5d78984ed",
"sha256": "59832e5b38c7ccfbaddf98fcc45d87fff36f71215e1cc85e481d93e7c2cd1190"
},
"downloads": -1,
"filename": "pymock_api-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "aba4a09d7dfdb05f0afc86e5d78984ed",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 54412,
"upload_time": "2024-03-26T04:09:52",
"upload_time_iso_8601": "2024-03-26T04:09:52.616933Z",
"url": "https://files.pythonhosted.org/packages/63/1b/73346e2e3649547e10c7ca55b9d04991ab81b01b430e9d6c0045c42bb3f6/pymock_api-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-26 04:09:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Chisanan232",
"github_project": "PyMock-API",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "pymock-api"
}