{ "info": { "author": "Adrian Dankiv", "author_email": "adr-007@ukr.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing :: Mocking", "Topic :: Software Development :: Testing :: Unit" ], "description": "# Requests-Asserts\n\n[![CircleCI](https://circleci.com/gh/ADR-007/requests-asserts.svg?style=svg)](https://circleci.com/gh/ADR-007/requests-asserts)\n[![Coverage Status](https://coveralls.io/repos/github/ADR-007/requests-asserts/badge.svg?branch=master)](https://coveralls.io/github/ADR-007/requests-asserts?branch=master)\n[![PyPI version](https://badge.fury.io/py/requests-asserts.svg)](https://badge.fury.io/py/requests-asserts)\n![PyPI - License](https://img.shields.io/pypi/l/requests-asserts)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/requests-asserts)\n![PyPI - Status](https://img.shields.io/pypi/status/requests-asserts)\n\nThe decorator and context manager to mock and verify HTTP requests made by `requests` library for `unittest`.\n\n## How to install\n\n```\npip install requests-asserts\n```\n\n## How to use\n\nMake a list of `RequestMock` elements that contain all information about the expected request and response.\nUse `RequestMock.assert_requests(request_mocks)` with the list as a decorator or context manager.\n\n### Example\n```py\nimport requests\nfrom unittests import TestCase \n\ndef get_likes_on_post(username, password, post_id):\n access_token = requests.post(\n 'http://my.site/login',\n json={'username': username, 'password': password}\n ).json()['access_token']\n\n likes = requests.get(\n f'http://my.site/posts/{post_id}',\n headers={\n 'Accept': 'application/json', \n 'Authorization': f'Bearer {access_token}'\n }\n ).json()['likes']\n\n return likes\n\nclass TestGetLikesOnPost(TestCase):\n @RequestMock.assert_requests([\n RequestMock(\n request_url='http://my.site/login',\n request_json={'username': 'the name', 'password': 'the password'},\n request_method=RequestMock.Method.POST,\n response_json={\"access_token\": 'the-token'}\n ),\n RequestMock(\n request_url='http://my.site/posts/3',\n request_headers_contains={'Authorization': 'Bearer the-token'},\n response_json={'name': 'The cool story', 'likes': 42}\n )\n ])\n def test_get_likes_on_post(self):\n self.assertEqual(42, get_likes_on_post('the name', 'the password', 3))\n\n```\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ADR-007/requests-asserts", "keywords": "mock,requests,unittests,tests,http", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "requests-asserts", "package_url": "https://pypi.org/project/requests-asserts/", "platform": "", "project_url": "https://pypi.org/project/requests-asserts/", "project_urls": { "Homepage": "https://github.com/ADR-007/requests-asserts", "Repository": "https://github.com/ADR-007/requests-asserts" }, "release_url": "https://pypi.org/project/requests-asserts/0.1.3/", "requires_dist": [ "requests (>=2.22,<3.0)", "responses (>=0.14.0,<0.15.0)" ], "requires_python": ">=3.6,<4.0", "summary": "The library to help test your HTTP requests using unittests", "version": "0.1.3", "yanked": false, "yanked_reason": null }, "last_serial": 11519193, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9dad91b0a20e32b96d9903f7bda89f8b", "sha256": "42f9f7309c5d76b65221fcc90c02a8f4733e4a2186fcb5758c9377c58e4c7eb0" }, "downloads": -1, "filename": "requests_asserts-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9dad91b0a20e32b96d9903f7bda89f8b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 3784, "upload_time": "2019-10-27T23:39:07", "upload_time_iso_8601": "2019-10-27T23:39:07.468617Z", "url": "https://files.pythonhosted.org/packages/95/51/d7da9c8e41d0768d0e789807672d82dd87a77639c2b3387b8effd7155b46/requests_asserts-0.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a696267355f9e16376fd0f92fcd809d4", "sha256": "542e851c1c07f29e7a46f64994ac9309a8589296b7d985f8342beae566f6474f" }, "downloads": -1, "filename": "requests-asserts-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a696267355f9e16376fd0f92fcd809d4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 3380, "upload_time": "2019-10-27T23:39:05", "upload_time_iso_8601": "2019-10-27T23:39:05.117521Z", "url": "https://files.pythonhosted.org/packages/8d/03/f22614f5ab208e87ebabf519c603af73384c2d18064f535240766825d479/requests-asserts-0.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3614b679bb9e24ff22a4a5d4f0e6aa8a", "sha256": "6e328c7bfae043c02afa66333c45e764484175afd17083a62fe0cb144672234d" }, "downloads": -1, "filename": "requests_asserts-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3614b679bb9e24ff22a4a5d4f0e6aa8a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4470, "upload_time": "2019-10-27T23:53:52", "upload_time_iso_8601": "2019-10-27T23:53:52.225378Z", "url": "https://files.pythonhosted.org/packages/35/2f/4e51e8a02a7b7cff518cafca8d1eea508d6dd6f6901bb5d09734e6e0cd0a/requests_asserts-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3560ba04427f058cc9d366dc1aa1bdd1", "sha256": "d9974b8c264cf41f2ecf1a0b513a990ba188ce61d054695c0066980dfe64420c" }, "downloads": -1, "filename": "requests-asserts-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3560ba04427f058cc9d366dc1aa1bdd1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 4146, "upload_time": "2019-10-27T23:53:50", "upload_time_iso_8601": "2019-10-27T23:53:50.566762Z", "url": "https://files.pythonhosted.org/packages/9d/96/0285d37185fdf18695e245ec8f298b6658db0f2a776b5bffd42305449c5f/requests-asserts-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6d14dfad611bb1b28f664b857b80e944", "sha256": "ed1ba96801aa77b36e5408ac121617d3b46424a8c12a1bc327a0b664981b8790" }, "downloads": -1, "filename": "requests_asserts-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6d14dfad611bb1b28f664b857b80e944", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4537, "upload_time": "2019-11-09T18:29:30", "upload_time_iso_8601": "2019-11-09T18:29:30.522185Z", "url": "https://files.pythonhosted.org/packages/e1/29/77e9e0c5ab82eb31da88ed148d2886a0172657081c380c8a98e179767233/requests_asserts-0.1.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "6399b9112b73a78769ae024b47c96b86", "sha256": "4f5859f94c433e91bc6a299cac479d5e01a5d58d6f093cb44edba886d9f1412f" }, "downloads": -1, "filename": "requests-asserts-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6399b9112b73a78769ae024b47c96b86", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 4205, "upload_time": "2019-11-09T18:29:29", "upload_time_iso_8601": "2019-11-09T18:29:29.152876Z", "url": "https://files.pythonhosted.org/packages/c7/71/1b22c0ecbe360ebe23dd66685d14f92d3401dc6e6774863a004350b39e8f/requests-asserts-0.1.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "76918fac135ca2e285b0a59667630dc9", "sha256": "24db52fc09f4185e3a95535c6e24f682f071cb253b034534ab3f757506c751d2" }, "downloads": -1, "filename": "requests_asserts-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "76918fac135ca2e285b0a59667630dc9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4770, "upload_time": "2021-09-22T15:28:43", "upload_time_iso_8601": "2021-09-22T15:28:43.439244Z", "url": "https://files.pythonhosted.org/packages/20/d5/c418381bb4ec5fc7745e1ceab9130cc893917e0b553c83f4ac67752d95a9/requests_asserts-0.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "c2641dc1808354e25b31a0acea395db0", "sha256": "9905605c6c4f23ae36a8882836506bb7fb55c2c43414a7524b68e5a24b9e0841" }, "downloads": -1, "filename": "requests-asserts-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c2641dc1808354e25b31a0acea395db0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 4628, "upload_time": "2021-09-22T15:28:42", "upload_time_iso_8601": "2021-09-22T15:28:42.371945Z", "url": "https://files.pythonhosted.org/packages/11/8a/3485cd37e9218d477e505b4b8da8463249b7fa310b206606670f900af632/requests-asserts-0.1.3.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "76918fac135ca2e285b0a59667630dc9", "sha256": "24db52fc09f4185e3a95535c6e24f682f071cb253b034534ab3f757506c751d2" }, "downloads": -1, "filename": "requests_asserts-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "76918fac135ca2e285b0a59667630dc9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4770, "upload_time": "2021-09-22T15:28:43", "upload_time_iso_8601": "2021-09-22T15:28:43.439244Z", "url": "https://files.pythonhosted.org/packages/20/d5/c418381bb4ec5fc7745e1ceab9130cc893917e0b553c83f4ac67752d95a9/requests_asserts-0.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "c2641dc1808354e25b31a0acea395db0", "sha256": "9905605c6c4f23ae36a8882836506bb7fb55c2c43414a7524b68e5a24b9e0841" }, "downloads": -1, "filename": "requests-asserts-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c2641dc1808354e25b31a0acea395db0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 4628, "upload_time": "2021-09-22T15:28:42", "upload_time_iso_8601": "2021-09-22T15:28:42.371945Z", "url": "https://files.pythonhosted.org/packages/11/8a/3485cd37e9218d477e505b4b8da8463249b7fa310b206606670f900af632/requests-asserts-0.1.3.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }