https://github.com/ezequielramos/http-server-mock
Python 3 library to mock a http server using Flask
https://github.com/ezequielramos/http-server-mock
http http-server mock python3 unittest
Last synced: about 1 month ago
JSON representation
Python 3 library to mock a http server using Flask
- Host: GitHub
- URL: https://github.com/ezequielramos/http-server-mock
- Owner: ezequielramos
- License: gpl-3.0
- Created: 2019-07-04T01:19:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-22T03:32:13.000Z (over 2 years ago)
- Last Synced: 2025-09-28T05:27:03.001Z (9 months ago)
- Topics: http, http-server, mock, python3, unittest
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 12
- Watchers: 0
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
http-server-mock
================
.. image:: https://img.shields.io/pypi/v/http-server-mock.svg
:target: https://pypi.python.org/pypi/http-server-mock
:alt: http-server-mock on PyPI (Python Package Index)
.. image:: https://travis-ci.org/ezequielramos/http-server-mock.svg?branch=master
:target: https://travis-ci.org/ezequielramos/http-server-mock
:alt: Travis CI tests (Linux)
.. image:: https://coveralls.io/repos/github/ezequielramos/http-server-mock/badge.svg?branch=master
:target: https://coveralls.io/github/ezequielramos/http-server-mock?branch=master
:alt: Test coverage on Coveralls
http-server-mock is a HTTP Server Mock using Flask. You can use it to test possible integrations with your application.
http-server-mock is available on PyPI. To install it just run:
::
pip install http-server-mock
Using http-server-mock is similar to implement any Flask application.
.. code:: python
from http_server_mock import HttpServerMock
import requests
app = HttpServerMock(__name__)
@app.route("/", methods=["GET"])
def index():
return "Hello world"
with app.run("localhost", 5000):
r = requests.get("http://localhost:5000/")
# r.status_code == 200
# r.text == "Hello world"
HttpServerMock will use a random route to know if the http server is running, if you want to set a specific route to do it just set the parameter is_alive_route:
.. code:: python
from http_server_mock import HttpServerMock
app = HttpServerMock(__name__, is_alive_route="/is-alive")