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.
Mockpy can be installed as a python wheel using
pip or as a standalone binary using
Make sure you have pip installed.
Run the following to install mockpy
pip install mockpy
Install using brew tap
brew tap oarrabi/tap brew install mockpy
Bellow is a description of the basic operations that
mockpy provides, for a more complete understanding please refer to the wikis.
Initialize a the current folder by running:
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.
The mock server can be started as a standalone web server, or as a proxy server.
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.
To start mockpy in proxy server mode use
mockpy start -x. This command does the following: