{ "info": { "author": "Marek Podsiad\u0142y", "author_email": "marek@podsiadly.info", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "PyMoq\n=====\n\nPyMoq is a tool for mocking HTTP services.\n\n\nInstallation\n------------\n\n::\n\n pip install PyMoq\n\n\nUsage\n-----\n\nBy default PyMoq runs on 8080 TCP port, it can be changed:\n\n::\n\n mock = pymoq.Mock(port=8090)\n\nStub can be created by setting path and http method (GET is the default).\n\n::\n\n mock.create_stub('/books', method='post')\n\nIt is possible to set path as regex.\n\n::\n\n mock.create_stub('/books/[0-9]+', method='put')\n\nFor each stub a response can be configured with headers and http status code.\nHeaders has to be dictionary with header name as its key.\n\n::\n\n mock.create_stub('/books', method='post').response('...',\n headers={'name': 'value'},\n http_status=201)\n\n\nExample test\n^^^^^^^^^^^^\n::\n\n import unittest\n import requests\n from pymoq import pymoq\n\n class ExampleUsageTestCase(unittest.TestCase):\n def test_direct_usage(self):\n content = '{\"author\": \"John Doe\", \"title\": \"Lorem ipsum dolor sit amet\", \"id\": 1}'\n headers = {\n 'content-type': 'application/json; charset=utf-8',\n 'location': 'http://localhost:8090/books/1'\n }\n\n mock = pymoq.Mock(port=8090)\n mock.create_stub('/books', method='post').response(content,\n headers=headers,\n http_status=201)\n\n with mock.run():\n response = requests.post('http://localhost:8090/books',\n data={\"author\": \"John Doe\", \"title\": \"Lorem ipsum dolor sit amet\"})\n self.assertEqual(response.status_code, 201)\n self.assertEqual(response.headers['content-type'], 'application/json; charset=utf-8')\n self.assertEqual(response.headers['location'], 'http://localhost:8090/books/1')\n self.assertEqual(response.text, content)\n\nConfigure with JSON file\n------------------------\n\nA mock can be configured with json file. A file should looks like:\n\n::\n\n [{\n \"request\": {\n \"url\": \"/books\",\n \"method\": \"post\"\n },\n \"response\": {\n \"content\": {\"author\": \"John Doe\", \"title\": \"Lorem ipsum dolor sit amet\", \"id\": 1},\n \"headers\": {\n \"content-type\": \"application/json; charset=utf-8\",\n \"location\": \"http://localhost:8080/books/1\"\n },\n \"httpStatus\": 201\n }\n }]\n\nExample test\n^^^^^^^^^^^^\n::\n\n import unittest\n import requests\n from pymoq import pymoq\n\n\n class JsonConfigTestCase(unittest.TestCase):\n def test_load_config_from_file(self):\n mock = pymoq.Mock()\n mock.load('config.json')\n\n with mock.run():\n response = requests.post('http://localhost:8080/books',\n data={\"author\": \"John Doe\", \"title\": \"Lorem ipsum dolor sit amet\"})\n self.assertEqual(response.status_code, 201)\n self.assertEqual(response.headers['content-type'], 'application/json; charset=utf-8')\n self.assertEqual(response.headers['location'], 'http://localhost:8080/books/1')\n\n content = response.json()\n self.assertEqual(content['author'], 'John Doe')\n self.assertEqual(content['title'], 'Lorem ipsum dolor sit amet')\n self.assertEqual(content['id'], 1)\n\nRequest verifications\n---------------------\nPyMoq can be used to validate requests.\n\nExample test\n^^^^^^^^^^^^\n::\n\n import unittest\n import requests\n from pymoq import pymoq\n\n\n class RequestVerificationTestCase(unittest.TestCase):\n def test_request(self):\n mock = pymoq.Mock()\n stub = mock.create_stub('/books', method='post')\n\n with mock.run():\n requests.post('http://localhost:8080/books',\n json={'firstName': 'John', 'lastName': 'Doe'}\n headers={'content-type': 'application/json'})\n\n stub.assert_requested_once()\n stub.assert_requested_with_header('content-type', 'application/json')\n stub.assert_requested_body_contains('Doe')\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/snifter/pymoq", "keywords": "api testing mocking", "license": "", "maintainer": "", "maintainer_email": "", "name": "PyMoq", "package_url": "https://pypi.org/project/PyMoq/", "platform": "", "project_url": "https://pypi.org/project/PyMoq/", "project_urls": { "Homepage": "https://github.com/snifter/pymoq" }, "release_url": "https://pypi.org/project/PyMoq/0.3.2/", "requires_dist": [ "requests; extra == 'test'" ], "requires_python": "", "summary": "An API mocking tool", "version": "0.3.2" }, "last_serial": 3727422, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "c138d5ad75b3e1fe58c9078cfff65bc5", "sha256": "65fea8295e30bc8dd98cbb94ef9fc2055bcfc753a7cb0f6ad14ef36b1d74c9a8" }, "downloads": -1, "filename": "PyMoq-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c138d5ad75b3e1fe58c9078cfff65bc5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4761, "upload_time": "2017-12-19T19:41:29", "url": "https://files.pythonhosted.org/packages/b1/86/e590245518c14233c56ce3d5dfa0f06b33f70a7f5257ab59e18a25628539/PyMoq-0.1.0-py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "9ba198feae63f915636c0c67fbecc238", "sha256": "6c317d75209782dfca5cee1764c9093c82bf22e94ab7c0d1da8fdab6873fc131" }, "downloads": -1, "filename": "PyMoq-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9ba198feae63f915636c0c67fbecc238", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7220, "upload_time": "2017-12-28T19:00:17", "url": "https://files.pythonhosted.org/packages/2b/f4/6fb20c79f0b873bfb2bcdfe1b16f3093c8880fb57ba0dbf3cc5afea37036/PyMoq-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "04a08b2aab6f7137a164873268fa393a", "sha256": "4d3c7a94de3b5858a2a31004f2eebe06a69d61a609a86fe4a6af50ecd2f6e209" }, "downloads": -1, "filename": "PyMoq-0.2.0.tar.gz", "has_sig": false, "md5_digest": "04a08b2aab6f7137a164873268fa393a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4140, "upload_time": "2017-12-28T19:00:19", "url": "https://files.pythonhosted.org/packages/c8/13/646fcdd345f6c5eade4e759d306d15a9cde889a8f6cfc30f2ed7b8d3b303/PyMoq-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "606026373b2a4e9b8686a12a69e9f093", "sha256": "911fe532c34124dd1ddad60de0eed8c09529d3781e449f94dbd20c40751163e3" }, "downloads": -1, "filename": "PyMoq-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "606026373b2a4e9b8686a12a69e9f093", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6271, "upload_time": "2018-04-02T19:47:27", "url": "https://files.pythonhosted.org/packages/a5/82/08e9165f902f3f8295bf6ca8e0538544e808e89adf252f7860d0ffba93de/PyMoq-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "59c4455bb7e59682d4f351251a8fbe48", "sha256": "b7f7a71945724a8b45fe2c4c0001cf15f09307033bb6b8be157e52b9f4d37abe" }, "downloads": -1, "filename": "PyMoq-0.3.0.tar.gz", "has_sig": false, "md5_digest": "59c4455bb7e59682d4f351251a8fbe48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4862, "upload_time": "2018-04-02T19:47:29", "url": "https://files.pythonhosted.org/packages/88/01/6ec04e5ffff122740037c05694c914fc537cec1682c6913c151cc031d571/PyMoq-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "35bda37e83f9c3b169e2d3485ddb5301", "sha256": "00d1251878a6c252c1ea3b82037d8a16a3920659e96923b6783cc2793e2261f9" }, "downloads": -1, "filename": "PyMoq-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "35bda37e83f9c3b169e2d3485ddb5301", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6272, "upload_time": "2018-04-02T19:57:24", "url": "https://files.pythonhosted.org/packages/34/44/f99b49395d303122b41c996096520d570425d16f1568724bdcbb58d12332/PyMoq-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b12937c1dfe6086653357f6b3b231fb3", "sha256": "37eb89e16627a8abe5227abb7e03613db77159a0b9f14feca7b7d48c3a7b48f5" }, "downloads": -1, "filename": "PyMoq-0.3.1.tar.gz", "has_sig": false, "md5_digest": "b12937c1dfe6086653357f6b3b231fb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4862, "upload_time": "2018-04-02T19:57:25", "url": "https://files.pythonhosted.org/packages/20/d4/a71cb374e67dc1917c15b2f17adbc0adac1c57a7a473f684ba2fa1601629/PyMoq-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "24dbd0ec89ba107037e36fad254166bf", "sha256": "c0e8d19424f61667bdb8911a5eb91d8fb2810b337c6a31929f3485d19135f70d" }, "downloads": -1, "filename": "PyMoq-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "24dbd0ec89ba107037e36fad254166bf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6162, "upload_time": "2018-04-02T20:08:09", "url": "https://files.pythonhosted.org/packages/6f/cd/9c1a621e8a705b7f7f2a45ced9f463d7dbd5ce1f3717dea00bae23bb717e/PyMoq-0.3.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01e4df936d7746772b6f5d9bdd662377", "sha256": "411cc8d63fa5868c801ee22a9e3a2064a019dcbe0b8352ef7f948457593344b4" }, "downloads": -1, "filename": "PyMoq-0.3.2.tar.gz", "has_sig": false, "md5_digest": "01e4df936d7746772b6f5d9bdd662377", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4710, "upload_time": "2018-04-02T20:08:10", "url": "https://files.pythonhosted.org/packages/9b/9d/d22a6134373cda4233c01f3fe41f9e1ac3e57fe2069c9864d3ec9696c17e/PyMoq-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "24dbd0ec89ba107037e36fad254166bf", "sha256": "c0e8d19424f61667bdb8911a5eb91d8fb2810b337c6a31929f3485d19135f70d" }, "downloads": -1, "filename": "PyMoq-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "24dbd0ec89ba107037e36fad254166bf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6162, "upload_time": "2018-04-02T20:08:09", "url": "https://files.pythonhosted.org/packages/6f/cd/9c1a621e8a705b7f7f2a45ced9f463d7dbd5ce1f3717dea00bae23bb717e/PyMoq-0.3.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01e4df936d7746772b6f5d9bdd662377", "sha256": "411cc8d63fa5868c801ee22a9e3a2064a019dcbe0b8352ef7f948457593344b4" }, "downloads": -1, "filename": "PyMoq-0.3.2.tar.gz", "has_sig": false, "md5_digest": "01e4df936d7746772b6f5d9bdd662377", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4710, "upload_time": "2018-04-02T20:08:10", "url": "https://files.pythonhosted.org/packages/9b/9d/d22a6134373cda4233c01f3fe41f9e1ac3e57fe2069c9864d3ec9696c17e/PyMoq-0.3.2.tar.gz" } ] }