Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

mock-server is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
 
Links
Author
License
http://www.apache.org/licenses/LICENSE-2.0

Mock server

Simple mock server for REST and XML-RPC API

It can mock GET, POST, PUT, PATCH, DELETE and some more rarely used HTTP methods.

Build status at Travis CI: travis

Installation

Install with pip:

$ pip install mock-server

Or install with easy_install:

$ easy_install mock-server

And after run:

$ mock-server --dir=/path/to/api

It will be listening on port 8888 and wait for your HTTP requests.

Overview

For create mock for url path go to:


Mocked GET /user/tom:

$ curl -v -X GET http://mockapi.org/user/tom

> GET /user/tom HTTP/1.1
> Host: mockapi.org
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 64
< Server: TornadoServer/2.4.1
<
{
    "name": "Tom",
    "surname": "Smith",
    "age": 22
}

Features

  • Mocking REST API.
  • Mocking RPC API (xml, json).
  • Upstream server proxy (proxy an existing api).
  • Variables in url path.
  • Simple api documentation (markdown).
  • Api authentication (HTTP Basic authentication).

Format

response content format: %METHOD%_%STATUS%.%FORMAT%

response headers format: %METHOD%_H_%STATUS%.%FORMAT%

root_dir/
    GET_200.json         # response content for GET /
    GET_H_200.json       # headers for GET /
    user/
        DELETE_404.xml   # response content for DELETE /user.xml?__statusCode=404
        POST_200.json    # response content for POST /user
        POST_H_200.json  # headers for POST /user

Bug report

If you have any trouble, report bug at GitHub Issue https://github.com/tomashanacek/mock-server/issues

History

0.3.2
  • todo escaping fix
0.3.1
  • support for todos in api documentation
  • access log improvements
0.3
  • upstream server proxy (proxy an existing api)
  • variables in url path
  • simple api documentation (markdown)
  • api authentication (HTTP Basic authentication)
  • manage interface improvements

No notes on earlier releases.

Subscribe to package updates

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.