{ "info": { "author": "Parviz Khavari", "author_email": "csctclan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", "Typing :: Typed" ], "description": "[![Build Status](https://travis-ci.org/zeburek/python-apitist.svg?branch=master)](https://travis-ci.org/zeburek/python-apitist)\n\n# python-apitist\n\nBrand new way to test your API\n\n# Installation\n\nActually project is not published on PyPi,\nso the only way:\n```bash\npip install python-apitist\n```\n\n# Default hooks\n\n- RequestDebugLoggingHook\n- RequestInfoLoggingHook\n- PrepRequestDebugLoggingHook\n- PrepRequestInfoLoggingHook\n- ResponseDebugLoggingHook\n- ResponseInfoLoggingHook\n\n## Example usage\n\n```python\nfrom apitist.hooks import PrepRequestInfoLoggingHook, ResponseInfoLoggingHook\nfrom apitist.requests import session\n\n\ns = session()\nPrepRequestInfoLoggingHook.formatter = \"Best formatter {req.method} {req.url}\"\n\ns.add_prep_request_hook(PrepRequestInfoLoggingHook)\ns.add_response_hook(ResponseInfoLoggingHook)\n\ns.post(\"https://httpbin.org/post\", params={\"q\": \"test\"})\n```\n\n# Custom Hooks\n\n```python\nfrom requests import Request, PreparedRequest, Response\n\nfrom apitist.requests import session, RequestHook, PreparedRequestHook, ResponseHook\n\ns = session()\n\nclass ReqHook(RequestHook):\n\n def run(self, request: Request) -> Request:\n print(request.url)\n return request\n\nclass PrepReqHook(PreparedRequestHook):\n\n def run(self, request: PreparedRequest) -> PreparedRequest:\n print(request.url)\n return request\n\n\nclass RespHook(ResponseHook):\n\n def run(self, response: Response) -> Response:\n print(response.url)\n return response\n\ns.add_request_hook(ReqHook)\ns.add_prep_request_hook(PrepReqHook)\ns.add_response_hook(RespHook)\n\ns.get(\"https://ya.ru\", params={\"q\": \"test\"})\n```\n\n# Working with constructor\n\n```python\nimport attr\nimport typing\n\nfrom apitist.constructor import converter\nfrom apitist.hooks import RequestConverterHook, ResponseConverterHook\nfrom apitist.requests import session\n\n\nclass ExampleType:\n test = None\n\n@attr.s\nclass ExampleStructure:\n test: ExampleType = attr.ib()\n\n@attr.s\nclass TestResponse:\n args: typing.Dict = attr.ib()\n data: str = attr.ib()\n files: typing.Dict = attr.ib()\n form: typing.Dict = attr.ib()\n headers: typing.Dict = attr.ib()\n json: ExampleStructure = attr.ib()\n origin: str = attr.ib()\n url: str = attr.ib()\n\ns = session()\ns.add_hook(RequestConverterHook)\ns.add_hook(ResponseConverterHook)\n\ndef structure_example_type(data, type_):\n example = ExampleType()\n example.test = data\n return example\n\ndef unstructure_example_type(data):\n return data.test\n\nconverter.register_hooks(\n ExampleType, structure_example_type, unstructure_example_type\n)\n\nt = ExampleType()\nt.test = \"test\"\n\nstruc = ExampleStructure(t)\n\nres = s.post(\"https://httpbin.org/post\", data=struc).structure(TestResponse)\nprint(res.structured.json.test.test) # test\n```\n\n# Using random data generator\n\nFirst of all create an instance of random class:\n\n```python\nfrom apitist.random import Randomer\nrand = Randomer()\n```\n\nNow, you can add custom hooks for different types:\n\n```python\nrand.add_type(str, lambda: str(random.random()))\nrand.add_type(float, lambda: random.random())\n```\n\nOr using `add_types`:\n\n```python\ntypes = {\n str: lambda: str(random.random()),\n float: lambda: random.random()\n}\nrand.add_types(types)\n```\n\nNow you can create random object for given type or any attrs class with\ndefined types:\n\n```python\nimport attr\nimport typing\n\nrand.object(str) # '0.6147789314561384'\nrand.object(float) # 0.4664297665239271\n\n@attr.s\nclass Data:\n value1: str = attr.ib()\n value2: typing.List[str] = attr.ib()\n value3: typing.Tuple[float] = attr.ib()\n\nprint(rand.object(Data))\n# Data(\n# value1='0.491058956716827',\n# value2=['0.6568036485871975'],\n# value3=(0.8603579349502298,)\n# )\n```\n\nIt is better to use it with [Faker](https://github.com/joke2k/faker).\nJust define different subclasses for `str` and add different hooks for them.\nBy this you could create different data for different `str` fields.\n\nAlso, using with `RequestConverterHook` and `ResponseConverterHook`\nyou could easily create random json objects which would be send to server.\n\n\n", "description_content_type": "text/markdown; charset=UTF-8", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zeburek/python-apitist", "keywords": "", "license": "gpl3", "maintainer": "", "maintainer_email": "", "name": "python-apitist", "package_url": "https://pypi.org/project/python-apitist/", "platform": "any", "project_url": "https://pypi.org/project/python-apitist/", "project_urls": { "Homepage": "https://github.com/zeburek/python-apitist" }, "release_url": "https://pypi.org/project/python-apitist/0.1.2/", "requires_dist": [ "attrs", "cattrs", "pendulum", "requests", "pytest ; extra == 'testing'", "pytest-cov ; extra == 'testing'", "testfixtures ; extra == 'testing'" ], "requires_python": ">=3.6", "summary": "Brand new way to test your API", "version": "0.1.2" }, "last_serial": 5719197, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "2483f362b050af83248c1f4c32acceb1", "sha256": "b0d01b3c10e5e36b794e3167d88bb6f647d9785fcceb75b4b1fb769aaab0bd7b" }, "downloads": -1, "filename": "python_apitist-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2483f362b050af83248c1f4c32acceb1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.4", "size": 18362, "upload_time": "2019-08-09T19:19:11", "url": "https://files.pythonhosted.org/packages/8f/63/23f9cb81606279269c9c140d2b46f30e3404763ab91cc319eb8e9f2f299e/python_apitist-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d0922494a6c844f2739f283a25eb6ec", "sha256": "bab872ccdd5aaf367ba741aa1d038497dbcd3b4adcb8abcbb32c4d654f27c896" }, "downloads": -1, "filename": "python-apitist-0.0.3.tar.gz", "has_sig": false, "md5_digest": "2d0922494a6c844f2739f283a25eb6ec", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 25255, "upload_time": "2019-08-09T19:19:13", "url": "https://files.pythonhosted.org/packages/10/47/89fae4f35644a904c23aba403c26b643f17bbc9b470c816f1724da03ac58/python-apitist-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "16de862d0b7163fb3ea7a7eb94e987f7", "sha256": "47f1a425997157f11462822341511046f3b8464b74970c3d9ac3aaf3ae0d0d5c" }, "downloads": -1, "filename": "python_apitist-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "16de862d0b7163fb3ea7a7eb94e987f7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.4", "size": 20189, "upload_time": "2019-08-11T15:58:59", "url": "https://files.pythonhosted.org/packages/24/c8/e06d21e819f0e7a81f4cc9123c4a716f588b2c7588cde78489ffccacb220/python_apitist-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "226d5a6fcf2ee6b3cd434c97f1ca2426", "sha256": "fd3373112263e889cef83b6ff370ea9dedf9833d4a7afce1e33ed4a5bb9d203b" }, "downloads": -1, "filename": "python-apitist-0.0.4.tar.gz", "has_sig": false, "md5_digest": "226d5a6fcf2ee6b3cd434c97f1ca2426", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 28238, "upload_time": "2019-08-11T15:59:01", "url": "https://files.pythonhosted.org/packages/db/1c/03fabb77a92a6f5fbb86c9223c7d62a357912923a29065e28efb1d0382ae/python-apitist-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "c6f531652ddd54c4cd52600c76980e3b", "sha256": "32a33da8d3d89b57a2ba7c7ecaf68368c90834ba77c234294e0a095f3b7cdfc4" }, "downloads": -1, "filename": "python_apitist-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c6f531652ddd54c4cd52600c76980e3b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 23048, "upload_time": "2019-08-17T19:13:01", "url": "https://files.pythonhosted.org/packages/90/39/d4c5d1c86b48c95782cb810acdc566c76e270516d3fddce1f839554efa28/python_apitist-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "64d9997af2315f87a09dcd5e7d5db001", "sha256": "36a14bdb6aa08588340fcf06c5a798961bb206812f1f297a5816ec891652bd0d" }, "downloads": -1, "filename": "python-apitist-0.0.5.tar.gz", "has_sig": false, "md5_digest": "64d9997af2315f87a09dcd5e7d5db001", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 33300, "upload_time": "2019-08-17T19:13:03", "url": "https://files.pythonhosted.org/packages/ca/2a/d40bfb22479dc114daa224ed6d3e7476ede9dc04177f1e2250a998adff8c/python-apitist-0.0.5.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "607945649d670f08e4655d193c69a3e2", "sha256": "40f4786c312498f72c0cf7146e57c2caad22c7ee98c96e74011653a074118711" }, "downloads": -1, "filename": "python_apitist-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "607945649d670f08e4655d193c69a3e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 21720, "upload_time": "2019-08-21T14:42:18", "url": "https://files.pythonhosted.org/packages/8e/8c/becb4e11e5b0ed5e39df667d2a96f4bf23e28616a1499f1cbb59dbdbf429/python_apitist-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "56237ff282859693bcaf38b6c56c25e2", "sha256": "9cab66d35124cddf055aac6595385ecb62af13d9c571a1c68cc34d50a377e5b4" }, "downloads": -1, "filename": "python-apitist-0.1.0.tar.gz", "has_sig": false, "md5_digest": "56237ff282859693bcaf38b6c56c25e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 31154, "upload_time": "2019-08-21T14:42:20", "url": "https://files.pythonhosted.org/packages/9f/14/79d7593bbb9ff8b169a45c7761a0fb756656ccc6b190668f8d6be4da90d0/python-apitist-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f9f767f2083b3121e0fe98f32c68207d", "sha256": "b1e0d6f1f286125a4c985d8bf306ada2e53ea18026941cf53b591fbe0b6aa891" }, "downloads": -1, "filename": "python_apitist-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f9f767f2083b3121e0fe98f32c68207d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 21794, "upload_time": "2019-08-23T06:47:56", "url": "https://files.pythonhosted.org/packages/e4/21/c79aeb840829bca08c3e1b9a1f848937465c25266fbfed20cfc9096de852/python_apitist-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "abf2d9b713af62ac1d114b6592800eaf", "sha256": "3fe607ee4da1d0e5a052d4db6a3a2b05cfaa4cd3bbd31c4451831e95b91b1c32" }, "downloads": -1, "filename": "python-apitist-0.1.1.tar.gz", "has_sig": false, "md5_digest": "abf2d9b713af62ac1d114b6592800eaf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 31213, "upload_time": "2019-08-23T06:48:00", "url": "https://files.pythonhosted.org/packages/b7/44/1dca570749015ffbab04809081e32066a307ec434d61b016a3de26b701f6/python-apitist-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6a3c0d3463f77672bbc73d733b20b1b6", "sha256": "af7ffe68bee28a00a244641fa1e2708bad30274612217f045442f84e77fbf714" }, "downloads": -1, "filename": "python_apitist-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6a3c0d3463f77672bbc73d733b20b1b6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 21500, "upload_time": "2019-08-23T06:59:12", "url": "https://files.pythonhosted.org/packages/92/64/db0580ad7ca015cd553bff4a7cc1ad76e0e03a764893ba360a7c3dc26f76/python_apitist-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5c71fa0a6632485e92f258fa46e5ee92", "sha256": "692a092f54677b0f72ef1c8f632f53700b8ba5df431deee1b347e2bfd145ce52" }, "downloads": -1, "filename": "python-apitist-0.1.2.tar.gz", "has_sig": false, "md5_digest": "5c71fa0a6632485e92f258fa46e5ee92", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 30875, "upload_time": "2019-08-23T06:59:16", "url": "https://files.pythonhosted.org/packages/ff/66/d4788665de69eda7e7c29e0ffcf4151d6f88c83e682a9661d07bee1d6424/python-apitist-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6a3c0d3463f77672bbc73d733b20b1b6", "sha256": "af7ffe68bee28a00a244641fa1e2708bad30274612217f045442f84e77fbf714" }, "downloads": -1, "filename": "python_apitist-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6a3c0d3463f77672bbc73d733b20b1b6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 21500, "upload_time": "2019-08-23T06:59:12", "url": "https://files.pythonhosted.org/packages/92/64/db0580ad7ca015cd553bff4a7cc1ad76e0e03a764893ba360a7c3dc26f76/python_apitist-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5c71fa0a6632485e92f258fa46e5ee92", "sha256": "692a092f54677b0f72ef1c8f632f53700b8ba5df431deee1b347e2bfd145ce52" }, "downloads": -1, "filename": "python-apitist-0.1.2.tar.gz", "has_sig": false, "md5_digest": "5c71fa0a6632485e92f258fa46e5ee92", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 30875, "upload_time": "2019-08-23T06:59:16", "url": "https://files.pythonhosted.org/packages/ff/66/d4788665de69eda7e7c29e0ffcf4151d6f88c83e682a9661d07bee1d6424/python-apitist-0.1.2.tar.gz" } ] }