Git Product home page Git Product logo

py-mock-server's Introduction

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:

http://localhost:8888/__manage/create

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).

Release new version

https://packaging.python.org/tutorials/packaging-projects/

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

py-mock-server's People

Contributors

tomashanacek avatar eduardosan avatar jollychang avatar winkidney avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.