{ "info": { "author": "Cyprien Guillemot", "author_email": "cyprien.guillemot@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": ".. image:: https://travis-ci.org/Trax-air/swagger-stub.svg?branch=master\n :alt: Travis status\n :target: https://travis-ci.org/Trax-air/swagger-stub\n.. image:: https://www.quantifiedcode.com/api/v1/project/bab4f51f0bc6420591f7a6cfe426a1c9/badge.svg\n :target: https://www.quantifiedcode.com/app/project/bab4f51f0bc6420591f7a6cfe426a1c9\n :alt: Code issues\n.. image:: https://badges.gitter.im/Trax-air/swagger-stub.svg\n :alt: Join the chat at https://gitter.im/Trax-air/swagger-stub\n :target: https://gitter.im/Trax-air/swagger-stub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\n.. image:: https://www.versioneye.com/user/projects/56b4ab470a0ff5003b975492/badge.svg\n :alt: Dependency Status\n :target: https://www.versioneye.com/user/projects/56b4ab470a0ff5003b975492\n.. image:: https://img.shields.io/pypi/v/swagger-stub.svg\n :target: https://pypi.python.org/pypi/swagger-stub/\n.. image:: https://img.shields.io/pypi/dw/swagger-stub.svg\n :target: https://pypi.python.org/pypi/swagger-stub/\n\nswagger-stub\n==============\n\nSwagger-stub create automatically a stub of your swagger REST API. This stub can be used anywhere you want like in a pytest fixture for your unit test.\n\nIn addition of mocking your API, you can mock some call, and check every call that have been made to the API.\n\nRelated Libraries\n-----------------\nYou may find related libraries to this one:\n\n* https://github.com/Trax-air/swagger-tester: Auto-test your swagger API in your unit tests. All test calls are generated by your swagger file.\n* https://github.com/Trax-air/swagger-aggregator: Aggregate several swagger specs into one. Useful for your API gateways!\n* https://github.com/Trax-air/swagger-parser: A helper that parses swagger specs. You can access the HTTP actions / paths and some example data\n\nExample Usage\n-------------\n\n.. code:: python\n\n import pytest\n import requests\n\n from swagger_stub import swagger_stub\n\n # This is the fixture of your stub\n # You only need to specify the path of the swagger file and the address\n # where you want to bind your stub.\n @pytest.fixture\n def test_stub():\n return swagger_stub([('swagger.yaml', 'http://foo.com')]).next()\n\n # Then you can use this fixture anywhere you want like your API is really running.\n def test_swagger_stub(test_stub):\n # Get a definition example\n test_stub.definitions['Foo']\n\n # Check a simple call\n response = requests.get('http://foo.com/v1/bar/')\n assert response.status_code == 200\n assert response.json() == {\n 'foo': 'bar'\n }\n\n # Check that an invalid body cause an error\n response = requests.post('http://foo.com/v1/bar/', data='invalid data')\n assert response.status_code == 400\n\n # Mock a call\n test_stub.add_mock_call('get', '/test', {'mock': 'call'})\n response = requests.get('http://foo.com/v1/test')\n assert response.json() == {'mock': 'call'}\n\n # Set some side_effect like in the mock library\n test_stub.add_mock_side_effect('get', '/iter', [{'test': '1'}, {'test': '2'}, {'test': '3'}])\n response = requests.get('http://foo.com/v1/iter')\n assert response.json() == {'test': '1'}\n response = requests.get('http://foo.com/v1/iter')\n assert response.json() == {'test': '2'}\n response = requests.get('http://foo.com/v1/iter')\n assert response.json() == {'test': '3'}\n\n # This side effect will raise a custom error\n test_stub.add_mock_side_effect('get', '/error', Exception)\n\n with pytest.raises(Exception):\n response = requests.get('http://foo.com/v1/error')\n\nDocumentation\n-------------\n\nMore documentation is available at https://swagger-stub.readthedocs.org/en/latest/.\n\nSetup\n-----\n\n`make install` or `pip install swagger-stub`\n\nLicense\n-------\n\nswagger-stub is licensed under http://opensource.org/licenses/MIT.\n\n\n=======\nHistory\n=======\n\n0.2.1 (2016-6-6)\n------------------\n\n* Fix repeated base path.\n\n0.2.0 (2016-5-2)\n------------------\n\n* Add access to definition example.\n\n0.1.1 (2016-1-31)\n------------------\n\n* Change license to MIT.\n\n0.1 (2016-1-29)\n------------------\n\n* First release on PyPI.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Trax-air/swagger-stub", "keywords": "swagger,stub,API,REST,swagger-stub", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "swagger-stub", "package_url": "https://pypi.org/project/swagger-stub/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/swagger-stub/", "project_urls": { "Homepage": "https://github.com/Trax-air/swagger-stub" }, "release_url": "https://pypi.org/project/swagger-stub/0.2.1/", "requires_dist": [ "httpretty (>=0.8.14)", "pytest (>=2.7.0)", "swagger-parser (>=0.1)" ], "requires_python": "", "summary": "Generate a stub from a swagger file", "version": "0.2.1" }, "last_serial": 2153112, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "97fca24f7617893832bbf731dd3fd644", "sha256": "c1fe67bbdeb06bcdd2a2621ec85cc3b058eba9118e3b0a0041c54c51a3c404b9" }, "downloads": -1, "filename": "swagger_stub-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "97fca24f7617893832bbf731dd3fd644", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6920, "upload_time": "2016-01-29T15:21:34", "url": "https://files.pythonhosted.org/packages/92/29/b6e18399e2fcae67faced13d3fe012a1997f20f9c6eeea1d53af7916010f/swagger_stub-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d9e18a5a843befb29595226f3f13c6f2", "sha256": "fc81bfa74cb508d5c210ada2f980c387fb45e054647da279863b686f7afc4aab" }, "downloads": -1, "filename": "swagger_stub-0.1.tar.gz", "has_sig": false, "md5_digest": "d9e18a5a843befb29595226f3f13c6f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29093, "upload_time": "2016-01-29T15:21:42", "url": "https://files.pythonhosted.org/packages/11/15/c22786ee881c5234bf01339ba70da873fb8b83826dca2086719b3b319cfe/swagger_stub-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4f80248e4ee091616731d006f089129b", "sha256": "f9fb89c2876f689525ea9d4d0b830eb2e1ab94da5dee8b6dcbbc98753c64554c" }, "downloads": -1, "filename": "swagger_stub-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4f80248e4ee091616731d006f089129b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6944, "upload_time": "2016-01-31T16:21:34", "url": "https://files.pythonhosted.org/packages/e6/cc/db2a1b8b79ae47436bcb1642582b96e78e92f017829849ffdd65da2d4d3a/swagger_stub-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c31f767c9d3c3250d58257f1ba3696a3", "sha256": "9f64be32e68dcfff61f5e2f08e9cb919c7a6d25f9a18caedf3df80c768a458d4" }, "downloads": -1, "filename": "swagger_stub-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c31f767c9d3c3250d58257f1ba3696a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17487, "upload_time": "2016-01-31T16:21:40", "url": "https://files.pythonhosted.org/packages/5a/3e/cea1aa0e09b5d7012d96de95a9efdc483a2e363713ee87f5e660c9926426/swagger_stub-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "dbfd930c8575afc7c4e6a23f05dd086f", "sha256": "a13c9084df9013a4b3772b46c62d011df1ab629cee7662210eb3aba60d49aede" }, "downloads": -1, "filename": "swagger_stub-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dbfd930c8575afc7c4e6a23f05dd086f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7497, "upload_time": "2016-02-05T16:40:52", "url": "https://files.pythonhosted.org/packages/c9/8d/babb0173df13fd3594dc9a6286289e2024ffd0d2b2298645c8bb292218ca/swagger_stub-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a363c8438e3e16349b7e743bd44bda7a", "sha256": "714b9d61b4976989cb9e27091e4462d0e8663ff22ba15cd89b320a659c24779b" }, "downloads": -1, "filename": "swagger_stub-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a363c8438e3e16349b7e743bd44bda7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18189, "upload_time": "2016-02-05T16:40:57", "url": "https://files.pythonhosted.org/packages/28/fb/2c790ac7cd3f0489f184067e840ffa6b4df5abcc3d186dcaca94004ada40/swagger_stub-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "febc9480fd96cf802da8e131354c5287", "sha256": "84eb254ccf94f6adb67a3a658e7f3f5a2d5007b3e32784b9b6461cde54c36c23" }, "downloads": -1, "filename": "swagger_stub-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "febc9480fd96cf802da8e131354c5287", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7898, "upload_time": "2016-06-06T14:08:58", "url": "https://files.pythonhosted.org/packages/21/4c/b41ed3f24142f3c8655286aeef928666c50708af4c075ec5173e8eca8b2e/swagger_stub-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0fb1c6d43e94d4089bef807289db56f", "sha256": "6ff47e489e183a5f981de9554228750a738cd18aaf2c7b140bff3680a0317db1" }, "downloads": -1, "filename": "swagger_stub-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d0fb1c6d43e94d4089bef807289db56f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18658, "upload_time": "2016-06-06T14:09:02", "url": "https://files.pythonhosted.org/packages/f0/dc/458bad9fbf7aa5747581ae0bde76fc087a61e2aed7852d269c6872b5a50c/swagger_stub-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "febc9480fd96cf802da8e131354c5287", "sha256": "84eb254ccf94f6adb67a3a658e7f3f5a2d5007b3e32784b9b6461cde54c36c23" }, "downloads": -1, "filename": "swagger_stub-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "febc9480fd96cf802da8e131354c5287", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7898, "upload_time": "2016-06-06T14:08:58", "url": "https://files.pythonhosted.org/packages/21/4c/b41ed3f24142f3c8655286aeef928666c50708af4c075ec5173e8eca8b2e/swagger_stub-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0fb1c6d43e94d4089bef807289db56f", "sha256": "6ff47e489e183a5f981de9554228750a738cd18aaf2c7b140bff3680a0317db1" }, "downloads": -1, "filename": "swagger_stub-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d0fb1c6d43e94d4089bef807289db56f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18658, "upload_time": "2016-06-06T14:09:02", "url": "https://files.pythonhosted.org/packages/f0/dc/458bad9fbf7aa5747581ae0bde76fc087a61e2aed7852d269c6872b5a50c/swagger_stub-0.2.1.tar.gz" } ] }