Metadata-Version: 2.0
Name: PyMoq
Version: 0.1.0
Summary: An API mocking tool
Home-page: https://github.com/snifter/pymoq
Author: Marek Podsiadły
Author-email: marek@podsiadly.info
License: UNKNOWN
Keywords: api testing mocking
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Provides-Extra: test
Requires-Dist: requests; extra == 'test'

PyMoq
=====
.. image:: https://travis-ci.org/snifter/pymoq.svg?branch=master
    :target: https://travis-ci.org/snifter/pymoq

PyMoq is a tool for mocking HTTP services.


Usage
-----

::

  content = '{"author": "John Doe", "title": "Lorem ipsum dolor sit amet", "id": 1}'
  headers = {
    'content-type': 'application/json; charset=utf-8',
    'location': 'http://localhost:8090/books/1'
  }

  mock = pymoq.Mock(port=8090)
  mock.create_stub('/books', method='post').response(content,
                                                     headers=headers,
                                                     httpStatus=201)

  with mock.run():
      response = requests.post('http://localhost:8090/books',
                        data={"author": "John Doe", "title": "Lorem ipsum dolor sit amet"})
      self.assertEqual(response.status_code, 201)
      self.assertEqual(response.headers['content-type'], 'application/json; charset=utf-8')
      self.assertEqual(response.headers['location'], 'http://localhost:8090/books/1')
      self.assertEqual(response.text, content)

