{ "info": { "author": "Dustin J. Mitchell", "author_email": "dustin@v.igoro.us", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "webmock\n=======\n\nThis tool provides an in-process WSGI server on an ephemeral port.\nIt is intended for use in unit tests, when the system under test makes outgoing HTTP connections that cannot easily be mocked.\n\nUsage\n-----\n\nFirst, create a WSGI application that represents the fake web server you want to create.\nThis is simpler than it seems; for example::\n\n def simple_app(environ, start_response):\n status = '200 OK'\n headers = [('Content-type', 'text/plain')]\n start_response(status, headers)\n return ['Hello, world!\\n']\n\nNext, activate the test server.\nThere are several ways to do this, but all of them produce a port number.\n\nAs a context manager::\n\n from mockweb import mock_server\n def test_web_request():\n with mock_server(simple_app) as port:\n my_client.get_greeting('http://127.0.0.1:{}'.format(port))\n\nAs a decorator::\n\n from mockweb import mock_server\n @mock_server(simple_app)\n def test_web_request(port):\n my_client.get_greeting('http://127.0.0.1:{}'.format(port))\n\nOr manually started and stopped::\n\n from mockweb import mock_server\n @mock_server\n def test_web_request():\n server = mock_server(simple_app)\n # ...\n server.start()\n my_client.get_greeting('http://127.0.0.1:{}'.format(port))\n server.stop()\n\nIn the latter case, be careful to stop the server.\n\nMock App\n--------\n\nThe ``webmock`` package includes a simple WSGI app which behaves like the Python ``Mock``: it accepts and records any request, and allows tests to make assertions after the operation is complete.\n\nIts usage is simple:\n\n from mockweb import mock_server, MockApp\n\n app = MockApp()\n with mock_server(app):\n # ..\n app.assert_called_with('GET /foo/bar')\n\nThe assertion methods available are:\n\n * ``assert_called_with(call)`` -- assert that the most recent request matches ``call``\n * ``assert_called_once_with(call)`` -- assert that only one request was made and that it matches ``call``\n * ``assert_any_call(call)`` -- assert that the any request matches ``call``\n * ``assert_has_call([call, call, ..], any_order=False)`` -- assert that the given calls all occurred.\n If ``any_order`` is false, the calls must be sequential.\n\nA call can be described with a string containing the method and the path.\n\nThe mock app's behavior can be adjusted in some minor ways.\nFor anything more complex, build a custom WSGI app.\n\n * ``MockApp(response='403 Forbidden')`` -- customize the HTTP response (default is \"200 OK\")\n * ``MockApp(body='hello world\\n')`` -- customize the response body (default is empty)\n * ``MockApp(headers=[('X-Auth', 'abc123')])`` -- customize the response headers", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": null, "keywords": "mock testing web http", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "webmock", "package_url": "https://pypi.org/project/webmock/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/webmock/", "project_urls": null, "release_url": "https://pypi.org/project/webmock/1.1.0/", "requires_dist": [ "nose; extra == 'test'", "coverage; extra == 'test'", "tox; extra == 'test'" ], "requires_python": null, "summary": "Mock web server for testing web clients", "version": "1.1.0" }, "last_serial": 1516997, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "417b2ee786186c7c2f4b9d9a2bacca2d", "sha256": "a56dc2c62d4c0748007f5865ac4d5bf5c8a1b8e8f8d850e103da266e26dfbea2" }, "downloads": -1, "filename": "webmock-1.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "417b2ee786186c7c2f4b9d9a2bacca2d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4648, "upload_time": "2015-04-17T23:40:48", "url": "https://files.pythonhosted.org/packages/89/ed/24f950c5f23c6550e01f05cfb14d497af4a78821e846449700b2ef02a1ce/webmock-1.0.0-py2.py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "97b7fef3e498103857a375036a123c20", "sha256": "b5d91585b0d942288ba04e8bb045024f68a83dcb3051f6c8a11e90c79be94628" }, "downloads": -1, "filename": "webmock-1.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "97b7fef3e498103857a375036a123c20", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6345, "upload_time": "2015-04-22T20:21:32", "url": "https://files.pythonhosted.org/packages/0a/ca/b5fb523b7d5613374dced997e006c1626955278f557f054f923974c444d1/webmock-1.1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "97b7fef3e498103857a375036a123c20", "sha256": "b5d91585b0d942288ba04e8bb045024f68a83dcb3051f6c8a11e90c79be94628" }, "downloads": -1, "filename": "webmock-1.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "97b7fef3e498103857a375036a123c20", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6345, "upload_time": "2015-04-22T20:21:32", "url": "https://files.pythonhosted.org/packages/0a/ca/b5fb523b7d5613374dced997e006c1626955278f557f054f923974c444d1/webmock-1.1.0-py2.py3-none-any.whl" } ] }