Skip to main content
# Mockpy

[![Build Status](https://travis-ci.org/oarrabi/mockpy.svg?branch=master)](https://travis-ci.org/oarrabi/mockpy)

Mockpy is a python open source line utility to quickly create mock servers on Mac OS X.
Mockpy is inspired by wiremock and uses libmproxy for the proxy functionality.

mockpy works by reading a list of configuration files in the YAML format, it uses these configurations to match the http request received and return an http response based on the matched YAML file configuration.

# Why mockpy
- You want a very lightweight utility to quickly create a mock API
- No need to edit your app code as it uses proxy mocking
- Works on top of proven technology ([mitmproxy](https://mitmproxy.org/) and [cherrypi](http://www.cherrypy.org/))
- Update to the mock API are picked up from files without the need to start/restart the server again.

# Installation

Mockpy can be installed as a python wheel using `pip` or as a standalone binary using `homebrew`

## Installing with pip

Make sure you have [pip](https://pip.pypa.io/en/latest/installing.html) installed.

Run the following to install mockpy

pip install mockpy

## Installing using brew
Install using brew tap

brew tap oarrabi/tap
brew install mockpy

# Usage

Bellow is a description of the basic operations that `mockpy` provides, for a more complete understanding please refer to [the wikis](https://github.com/oarrabi/mockpy/wiki).

## Initialize a directory
Initialize a the current folder by running:

mockpy init
This will create two folders:

`inout`: this folder will contains a list of mapping YAML files, each YAML file represents an request and response operation.

`res`: resource folder contains the static HTML, JSON, Images and static files returned as part of the mocking process.

To understand the YAML file format, please refer to the documentation.

## Start the mock server
The mock server can be started as a standalone web server, or as a proxy server.

### Standalone web server
Use `mockpy start` to start the standalone web server, this will setup a server on the default port. Visit `127.0.0.1:9090` to check the mock server.

### Proxy web server
To start mockpy in proxy server mode use `mockpy start -x`. This command does the following:
- Starts a proxy server on '127.0.0.1:9090'
- Sets the macs HTTP/HTTPS settings to the created proxy server.




History
-------

0.1.0 (2015-01-11)
---------------------

* First release on PyPI.

Metadata

Release files for mockpy 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mockpy 0.1.7
File Size Uploaded Provenance
mockpy-0.1.7.tar.gz 12.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mockpy 0.1.7
File Interpreter ABI Platform
mockpy-0.1.7-py2-none-any.whl Python 2 none any Details

Total release size: 31.9 kB

Release files / mockpy-0.1.7.tar.gz

Download URL mockpy-0.1.7.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7ac6a1e25540ee28c975d154999b2196401d8f7ca0c4293caf77ba9fcff17808
BLAKE2b-256 checksum
How to use checksums
0951ad57dff53fdb5794e0cb136b5bd3325b055bfb2f54962aaabda67567a959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mockpy-0.1.7-py2-none-any.whl

Download URL mockpy-0.1.7-py2-none-any.whl
Size 19.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
e3c65aa3268719d07fe0d7d036fa7f57de4133a8f4fdd3889a88887d29dd8696
BLAKE2b-256 checksum
How to use checksums
38f09d8e2008e4e2532fae45a19d2fdb8bb89632c36028721076bc1fb4237385
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mockpy 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page