{ "info": { "author": "Nikita Sivakov", "author_email": "sivakov512@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Pytest", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Testing" ], "description": "Pytest Falcon Client\n===\nPytest `client` fixture for the [Falcon Framework](https://github.com/falconry/falcon).\n\n[![Build Status](https://travis-ci.org/sivakov512/pytest-falcon-client.svg?branch=master)](https://travis-ci.org/sivakov512/pytest-falcon-client)\n[![Coverage Status](https://coveralls.io/repos/github/sivakov512/pytest-falcon-client/badge.svg?branch=master)](https://coveralls.io/github/sivakov512/pytest-falcon-client?branch=master)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n![Python versions](https://img.shields.io/badge/python-3.6,%203.7-blue.svg)\n[![PyPi](https://img.shields.io/pypi/v/pytest-falcon-client.svg)](https://pypi.python.org/pypi/pytest-falcon-client)\n\n## Installation\n\n``` shell\npip install pytest-falcon-client\n```\n\n## Setup\n\nPlugin provides `make_client` fixture that you can use as is by passing `falcon.API` instance as argument:\n``` python\nimport pytest\n\nfrom yout_application import create_api\n\n@pytest.fixture\ndef api():\n return create_api()\n\n\ndef test_something(make_client, api):\n client = make_client(api)\n\n got = client.get('/your_url/42/')\n\n assert got == {'awesome': 'response'}\n```\n\nFor simpler usage you can define your own `client` fixture:\n``` python\nimport pytest\n\nfrom yout_application import create_api\n\n@pytest.fixture\ndef client(make_client):\n api = create_api()\n return make_client(api)\n\n\ndef test_something(client):\n got = client.get('/your_url/42/')\n\n assert got == {'awesome': 'response'}\n```\n\n## Assertion examples\n\n### Get response body as json and do automatic assertions for status code\n\n``` python\ndef test_something(client):\n got = client.get('/your_url/42/')\n\n assert got == {'some': 'staff'}\n```\n\n### Get response body as json and do automatic assertions for your own status codes\n\n``` python\ndef test_something(client):\n got = client.get('/your_url/42/', expected_statuses=[400, 401])\n\n assert got == {'some': 'stuff'}\n```\n\n### Get response object as is and skip any automatic assertions\n\n``` python\ndef test_something(client):\n response = client.get('/your_url/42/', as_response=True)\n\n assert response.status_code == 400\n assert response.json == {'some': 'stuff'}\n```\n\n### Custom automatic assertions on every request\n\nFor example, you want to assert that every response has\n`Access-Control-Allow-Origin` header with value `falconframework.org`.\nYou can do it with custom `ApiTestClient` like this:\n``` python\nimport pytest\n\nfrom pytest_falcon_client import ApiTestClient\n\nfrom yout_application import create_api\n\n\nclass CustomApiTestClient(ApiTestClient):\n def response_assertions(self, response):\n # You can do any automatic assertions here for every request\n assert response.headers[\n 'Access-Control-Allow-Origin'] == 'falconframework.org'\n\n\n@pytest.fixture\ndef client():\n api = create_api()\n return CustomApiTestClient(api)\n\n\ndef test_something(client):\n response = client.get('/your_url/42/', as_response=True)\n\n assert response.status_code == 400\n assert response.json == {'some': 'stuff'}\n```\n\n\n### Simulate some default client behaviour\n\nWhat if you service depends on some default client behaviour, like headers,\ncookies or something else? You can setup this behaviour for every request\nwith custom `ApiTestClient`:\n``` python\nimport pytest\n\nfrom pytest_falcon_client import ApiTestClient\n\nfrom yout_application import create_api\n\n\nclass CustomApiTestClient(ApiTestClient):\n def prepare_request(self, method, expected_statuses, *args, **kwargs):\n kwargs['headers'] = {'Origin': 'falconframework.org'} # add `ORIGIN` header to every request\n return args, kwargs, expected_statuses # should returns all of this\n\n\n@pytest.fixture\ndef client():\n api = create_api()\n return CustomApiTestClient(api)\n\n\ndef test_something(client):\n got = client.get('/your_url/42/', as_response=True)\n\n assert got == {'some': 'stuff'}\n```\n\nLook at more examples in `tests`.", "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/sivakov512/pytest-falcon-client", "keywords": "pytest,fixture,falcon,client,api", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytest-falcon-client", "package_url": "https://pypi.org/project/pytest-falcon-client/", "platform": "", "project_url": "https://pypi.org/project/pytest-falcon-client/", "project_urls": { "Homepage": "https://github.com/sivakov512/pytest-falcon-client" }, "release_url": "https://pypi.org/project/pytest-falcon-client/2.0.1/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Pytest `client` fixture for the Falcon Framework", "version": "2.0.1" }, "last_serial": 4959815, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "3fa3c86e980e4dd4646ce18f8ae8d387", "sha256": "2118f1c8f4d40ec532d74c1b6371b75e2ee31a5e9525bc687b74491b9b82d186" }, "downloads": -1, "filename": "pytest-falcon-client-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3fa3c86e980e4dd4646ce18f8ae8d387", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 2588, "upload_time": "2018-02-08T09:05:48", "url": "https://files.pythonhosted.org/packages/e1/0d/b9a2797dea6bbca096ef16f970f2df05200c41b4e5ed3b617295097471b8/pytest-falcon-client-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "d24219f1813222638bbf6955b2ef11d1", "sha256": "dbdfc6c61c12c20cf3f10708be14408192a9f1d0578fff99cd2904bff7b287c0" }, "downloads": -1, "filename": "pytest-falcon-client-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d24219f1813222638bbf6955b2ef11d1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3004, "upload_time": "2018-02-13T08:55:04", "url": "https://files.pythonhosted.org/packages/36/82/1749f665817fe9b8d9e236b672d6889971deb7c8ba77aafd0355070ab5f7/pytest-falcon-client-0.1.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "d56fa7b853d7a5a82d215077837754f4", "sha256": "24d5a0e22a4d45ea24102da7d185f92aa18b3fcb9f6e8d55af9482c14b6354a9" }, "downloads": -1, "filename": "pytest-falcon-client-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d56fa7b853d7a5a82d215077837754f4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3045, "upload_time": "2018-03-09T05:10:34", "url": "https://files.pythonhosted.org/packages/e3/d0/cc785d6c2ce1ee25675cc1141108687c3ce1260f84acfcb06d07a20e2d42/pytest-falcon-client-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "201a7c7d9e1ee009bfc98f977758cb85", "sha256": "48ff3f6a5b685e8dac04ccf3778212935cd5b54d7d26fbdccf1cc26a89f05b65" }, "downloads": -1, "filename": "pytest-falcon-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "201a7c7d9e1ee009bfc98f977758cb85", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3029, "upload_time": "2018-04-29T13:55:15", "url": "https://files.pythonhosted.org/packages/0b/df/36b4e780f1ea629673d827415903bd2b5d019aa3093df2e51a07213786a5/pytest-falcon-client-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "d28f6a6298c97c3541af2699960de0c7", "sha256": "7ac1696842859a4be24f5f6233acf92015f2d9768147769dc9143bc55d66941f" }, "downloads": -1, "filename": "pytest-falcon-client-1.0.2.tar.gz", "has_sig": false, "md5_digest": "d28f6a6298c97c3541af2699960de0c7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 3026, "upload_time": "2018-04-29T14:13:51", "url": "https://files.pythonhosted.org/packages/22/f2/b2c2481010e52f546031e0f4914dacb57a271419a3f8a1a33e199923b99d/pytest-falcon-client-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "2f8061d9351c8e8fc6e9e32acc928e4a", "sha256": "26d7a2d520128ea4bbd8dd5a97c2fd7c486f2ddc495bd113772541c14fc36382" }, "downloads": -1, "filename": "pytest-falcon-client-1.0.3.tar.gz", "has_sig": false, "md5_digest": "2f8061d9351c8e8fc6e9e32acc928e4a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 2920, "upload_time": "2019-02-08T13:52:48", "url": "https://files.pythonhosted.org/packages/45/4a/150942930b79ade7b9d9da22a24b801e30301f824b7fda81b491c7665325/pytest-falcon-client-1.0.3.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "f865df80d6e3b11a7efb472e636c5d6e", "sha256": "87ac81ad7ca5665ddf8bc6caacd4fc124c5751c92cd9ef25c46e508203b1568b" }, "downloads": -1, "filename": "pytest-falcon-client-2.0.1.tar.gz", "has_sig": false, "md5_digest": "f865df80d6e3b11a7efb472e636c5d6e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3283, "upload_time": "2019-03-19T17:13:27", "url": "https://files.pythonhosted.org/packages/3e/c0/3c7f9019528ea87a8784460294ee4a92288886f21ff9a5314dd28e68414f/pytest-falcon-client-2.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f865df80d6e3b11a7efb472e636c5d6e", "sha256": "87ac81ad7ca5665ddf8bc6caacd4fc124c5751c92cd9ef25c46e508203b1568b" }, "downloads": -1, "filename": "pytest-falcon-client-2.0.1.tar.gz", "has_sig": false, "md5_digest": "f865df80d6e3b11a7efb472e636c5d6e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3283, "upload_time": "2019-03-19T17:13:27", "url": "https://files.pythonhosted.org/packages/3e/c0/3c7f9019528ea87a8784460294ee4a92288886f21ff9a5314dd28e68414f/pytest-falcon-client-2.0.1.tar.gz" } ] }