Skip to main content

Simple mock server for REST API

Project description

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

DEMO

http://demo.mockapi.org/__manage

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://demo.mockapi.org/user/tom

> GET /user/tom HTTP/1.1
> Host: demo.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

Contributors

William Zhang

History

0.3.8

  • fix http util when returning HTTPHeaders instance

  • fix Tornado version

  • Python 2.7 and 3.4 compatibility

Many thanks to @eduardosan and @winkidney

0.3.7

  • support for custom response provider

0.3.6

  • support for non-standard status codes

0.3.5

  • added num_processes command line option for possibility to start multiple worker processes

0.3.4

  • edit rpc method fix

0.3.3

  • create resource quotation character fix

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mock-server-0.3.8.tar.gz (341.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mock_server-0.3.8-py2-none-any.whl (374.7 kB view details)

Uploaded Python 2

File details

Details for the file mock-server-0.3.8.tar.gz.

File metadata

  • Download URL: mock-server-0.3.8.tar.gz
  • Upload date:
  • Size: 341.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mock-server-0.3.8.tar.gz
Algorithm Hash digest
SHA256 8e47e75e7ce0e057062a50097bddfebe824e769f774c2d47191667e2cecf6ad9
MD5 c2dd7d49f5dbeffca8b3660e16233443
BLAKE2b-256 96a50eab6db1d47f8856058562125a855417222dd496391505a74559e0d68c52

See more details on using hashes here.

File details

Details for the file mock_server-0.3.8-py2-none-any.whl.

File metadata

File hashes

Hashes for mock_server-0.3.8-py2-none-any.whl
Algorithm Hash digest
SHA256 82fb6f617e574ac605928d577a2ad772e12a3e7c5435f079d3278ed88f68aa3d
MD5 dd0e8ee2e63443b518b04a0d9c4a47e6
BLAKE2b-256 81b37ffcc9b0934071fd18b8f4e0ca5857e8e76188d21139a9d86cfcffac8a7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page