You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

mock-server

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-server

Simple mock server for REST API


Maintainers
1

Readme

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 <http://travis-ci.org/>_: |travis|

.. |travis| image:: https://travis-ci.org/tomashanacek/mock-server.png?branch=master :target: https://travis-ci.org/tomashanacek/mock-server

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

History

0.3.9

  • fix unicode 500 error
  • fix grammar when API does not exist

Many thanks to @bopo and @krmaxwell

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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc