webtest-plus


Namewebtest-plus JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/sloria/webtest-plus
SummaryAn extension of WebTest with useful extras, including requests-style authentication.
upload_time2017-05-12 02:31:01
maintainer
docs_urlNone
authorSteven Loria
requires_python
licenseCopyright 2017 Steven Loria Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords wsgi test unit tests web testing http
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            ============
webtest-plus
============

.. image:: https://badge.fury.io/py/webtest-plus.png
    :target: http://badge.fury.io/py/webtest-plus

.. image:: https://travis-ci.org/sloria/webtest-plus.png?branch=master
    :target: https://travis-ci.org/sloria/webtest-plus

An extension of `WebTest <http://webtest.pythonpaste.org/en/latest/>`_  with useful extras, including `requests <http://docs.python-requests.org/en/latest/>`_-style authentication.

Install
-------
.. code-block:: bash

    $ pip install -U webtest-plus

Usage
-----

.. code-block:: python

    import unittest
    from myapp import app
    from webtest_plus import TestApp

    class TestMyApp(unittest.TestCase):

        def setUp(self):
            self.app = TestApp(app)

        def test_protected_endpoint(self):
            response = self.app.get("/secret/", expect_errors=True)
            assert response.status_code == 401
            # Requests-style authentication
            response = self.app.get("/secret/", auth=("admin", "passw0rd"))
            assert response.status_code == 200

        def test_more_secrets(self):
            # Another way to authenticate
            self.app.authenticate(username="admin", password="passw0rd")
            assert self.app.get("/secret/").status_code == 200
            self.app.deauthenticate()
            assert self.app.get("/secret/", expect_errors=True).status_code == 401

        def test_posting_json(self):
            # Testing json requests and responses
            response = self.app.post_json("/postsecret/", {"secret": "myprecious"},
                                            auth=("admin", "passw0rd"))
            assert response.request.content_type == "application/json"

        def test_clicking(self):
            response = self.app.get("/")
            response = response.click("Protected link", auth=("admin", "passw0rd"))
            assert response.status_code == 200

        def test_token_auth(self):
            response = self.app.get('/secret-requires-token/', expect_errors=True)
            assert response.status_code == 401

            # Authenticate with JWT
            response = self.app.get('/secret-requires-token',
                auth='yourlongtokenhere', auth_type='jwt')
            assert response.status_code == 200



Features
--------

* Basic HTTP authentication
* `JSON Web Token <https://openid.net/specs/draft-jones-json-web-token-07.html>`_ authentication
* Auto-follow redirects
* Framework-agnostic

Requirements
------------

- Python >= 2.6 or >= 3.3

License
-------

MIT licensed. See the bundled `LICENSE <https://github.com/sloria/webtest-plus/blob/master/LICENSE>`_ file for more details.


Changelog
---------

1.0.0 (2017-05-17)
++++++++++++++++++

* Fix handling of utf-encoded values when using ``auth`` (#3). Thanks @biern for the catch and patch.
* Drop support for Python 2.6.
* Test against Python 3.6.

0.3.3 (2015-03-17)
++++++++++++++++++

* Implement ``TestApp.head``.

0.3.2 (2014-06-04)
++++++++++++++++++

* Bug fix that caused an ``UnboundLocalError``.

0.3.1 (2014-05-31)
++++++++++++++++++

* Fix string encoding bug on Python 2.

0.3.0 (2014-05-31)
++++++++++++++++++

* Add support for JSON web token authentication.

0.2.1 (2013-11-24)
++++++++++++++++++

* Add authentication to ``TestResponse.click`` and ``TestResponse.clickbutton``.

0.2.0 (2013-10-15)
++++++++++++++++++

* Add support for JSON methods (e.g. ``app.post_json``, etc.)

0.1.0 (2013-10-06)
++++++++++++++++++

* First release.
* HTTP Basic Authentication working.

            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "wsgi test unit tests web testing http", 
    "upload_time": "2017-05-12 02:31:01", 
    "author": "Steven Loria", 
    "home_page": "https://github.com/sloria/webtest-plus", 
    "github_user": "sloria", 
    "download_url": "https://pypi.python.org/packages/d3/9f/a05220d4c2dca02c1a0db58246aa2639f22665800b8366bd0306069e26a4/webtest-plus-1.0.0.tar.gz", 
    "platform": "", 
    "version": "1.0.0", 
    "cheesecake_documentation_id": null, 
    "description": "============\nwebtest-plus\n============\n\n.. image:: https://badge.fury.io/py/webtest-plus.png\n    :target: http://badge.fury.io/py/webtest-plus\n\n.. image:: https://travis-ci.org/sloria/webtest-plus.png?branch=master\n    :target: https://travis-ci.org/sloria/webtest-plus\n\nAn extension of `WebTest <http://webtest.pythonpaste.org/en/latest/>`_  with useful extras, including `requests <http://docs.python-requests.org/en/latest/>`_-style authentication.\n\nInstall\n-------\n.. code-block:: bash\n\n    $ pip install -U webtest-plus\n\nUsage\n-----\n\n.. code-block:: python\n\n    import unittest\n    from myapp import app\n    from webtest_plus import TestApp\n\n    class TestMyApp(unittest.TestCase):\n\n        def setUp(self):\n            self.app = TestApp(app)\n\n        def test_protected_endpoint(self):\n            response = self.app.get(\"/secret/\", expect_errors=True)\n            assert response.status_code == 401\n            # Requests-style authentication\n            response = self.app.get(\"/secret/\", auth=(\"admin\", \"passw0rd\"))\n            assert response.status_code == 200\n\n        def test_more_secrets(self):\n            # Another way to authenticate\n            self.app.authenticate(username=\"admin\", password=\"passw0rd\")\n            assert self.app.get(\"/secret/\").status_code == 200\n            self.app.deauthenticate()\n            assert self.app.get(\"/secret/\", expect_errors=True).status_code == 401\n\n        def test_posting_json(self):\n            # Testing json requests and responses\n            response = self.app.post_json(\"/postsecret/\", {\"secret\": \"myprecious\"},\n                                            auth=(\"admin\", \"passw0rd\"))\n            assert response.request.content_type == \"application/json\"\n\n        def test_clicking(self):\n            response = self.app.get(\"/\")\n            response = response.click(\"Protected link\", auth=(\"admin\", \"passw0rd\"))\n            assert response.status_code == 200\n\n        def test_token_auth(self):\n            response = self.app.get('/secret-requires-token/', expect_errors=True)\n            assert response.status_code == 401\n\n            # Authenticate with JWT\n            response = self.app.get('/secret-requires-token',\n                auth='yourlongtokenhere', auth_type='jwt')\n            assert response.status_code == 200\n\n\n\nFeatures\n--------\n\n* Basic HTTP authentication\n* `JSON Web Token <https://openid.net/specs/draft-jones-json-web-token-07.html>`_ authentication\n* Auto-follow redirects\n* Framework-agnostic\n\nRequirements\n------------\n\n- Python >= 2.6 or >= 3.3\n\nLicense\n-------\n\nMIT licensed. See the bundled `LICENSE <https://github.com/sloria/webtest-plus/blob/master/LICENSE>`_ file for more details.\n\n\nChangelog\n---------\n\n1.0.0 (2017-05-17)\n++++++++++++++++++\n\n* Fix handling of utf-encoded values when using ``auth`` (#3). Thanks @biern for the catch and patch.\n* Drop support for Python 2.6.\n* Test against Python 3.6.\n\n0.3.3 (2015-03-17)\n++++++++++++++++++\n\n* Implement ``TestApp.head``.\n\n0.3.2 (2014-06-04)\n++++++++++++++++++\n\n* Bug fix that caused an ``UnboundLocalError``.\n\n0.3.1 (2014-05-31)\n++++++++++++++++++\n\n* Fix string encoding bug on Python 2.\n\n0.3.0 (2014-05-31)\n++++++++++++++++++\n\n* Add support for JSON web token authentication.\n\n0.2.1 (2013-11-24)\n++++++++++++++++++\n\n* Add authentication to ``TestResponse.click`` and ``TestResponse.clickbutton``.\n\n0.2.0 (2013-10-15)\n++++++++++++++++++\n\n* Add support for JSON methods (e.g. ``app.post_json``, etc.)\n\n0.1.0 (2013-10-06)\n++++++++++++++++++\n\n* First release.\n* HTTP Basic Authentication working.\n", 
    "tox": true, 
    "lcname": "webtest-plus", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": true, 
    "name": "webtest-plus", 
    "license": "Copyright 2017 Steven Loria\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", 
    "travis_ci": true, 
    "github_project": "webtest-plus", 
    "summary": "An extension of WebTest with useful extras, including requests-style authentication.", 
    "split_keywords": [
        "wsgi", 
        "test", 
        "unit", 
        "tests", 
        "web", 
        "testing", 
        "http"
    ], 
    "author_email": "sloria1@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-05-12T02:31:01", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/d3/9f/a05220d4c2dca02c1a0db58246aa2639f22665800b8366bd0306069e26a4/webtest-plus-1.0.0.tar.gz", 
            "md5_digest": "27337684ba5b79e644bf36c70faf5575", 
            "downloads": 0, 
            "filename": "webtest-plus-1.0.0.tar.gz", 
            "packagetype": "sdist", 
            "path": "d3/9f/a05220d4c2dca02c1a0db58246aa2639f22665800b8366bd0306069e26a4/webtest-plus-1.0.0.tar.gz", 
            "size": 8903
        }, 
        {
            "has_sig": false, 
            "upload_time": "2017-05-12T02:31:02", 
            "comment_text": "", 
            "python_version": "3.5", 
            "url": "https://pypi.python.org/packages/7d/77/7c2bd17a367266f2a74f844917107fd2e5d876b219c96557df4ee4dde511/webtest_plus-1.0.0-py2.py3-none-any.whl", 
            "md5_digest": "fdc8bf81d810e7471415f5af95001905", 
            "downloads": 0, 
            "filename": "webtest_plus-1.0.0-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "path": "7d/77/7c2bd17a367266f2a74f844917107fd2e5d876b219c96557df4ee4dde511/webtest_plus-1.0.0-py2.py3-none-any.whl", 
            "size": 9772
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}