{ "info": { "author": "Jason Pellerin", "author_email": "jpellerin@leapfrogonline.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Testing" ], "description": "Trestle: doctest for REST(ful services)\n---------------------------------------\n\n\nAbout\n~~~~~\n\nTrestle is a nose plugin that enables you to write testable documentation for\nweb apps (or shell commands, but more on that later).\n\nTo use trestle, write a `reStructured Text`_ document (like this one) using a\nset of special directives to indicate the **fixtures** to be used for testing\n(including the http or mock http client), each **request** to be sent via the\nclient, and the **expected response** from the application under test.\n\nA simple trestle test document might look like this::\n\n Frog: A web service for doing things with frogs\n -----------------------------------------------\n\n .. fixtures :: frog_fixtures\n\n Frog is a web service for doing things with frogs.\n \n You can list the available frogs. \n \n .. request :: List available frogs\n\n GET /frogs\n ..\n\n The response is in a plain-text format.\n \n .. response ::\n \n bullfrog\n poison dart\n treefrog\n ...\n ..\n\n You can find out if something is a frog.\n\n .. request :: Get bullfrog details\n\n GET /frogs/bullfrog\n ..\n\n If the requested term is a frog, details about the frog will be returned.\n \n .. response ::\n\n Bullfrogs are really big frogs.\n ..\n\n Otherwise, a 404 response is returned.\n\n .. request :: Get details for a non-frog\n\n GET /frogs/toad\n ..\n\n .. response ::\n\n 404 ...\n ...\n \n \"toad\" is not a frog.\n ..\n\n You can create frogs.\n\n .. request :: Create a frog\n\n POST /frogs/pouched+frog\n A pouched frog camouflages itself to look like dead leaves.\n ..\n\n .. response ::\n\n 201 Created\n ...\n\n ...\n ..\n\nTrestle directives\n^^^^^^^^^^^^^^^^^^\n \nFixtures for a trestle test file are set like so::\n\n .. fixtures:: about\n\nA fixtures directive is required in every document to be tested. The\ndirective must name a python module. The module must include the\nfollowing attribute:\n \nclient\n A client application to be called with methods .get(), .post(),\n .put(), etc. Each method must accept at least the arguments url and\n data, and may accept others but may not require\n them. `paste.fixtures.TestApp`_ is such a client, though it natively\n supports only .get() and .post().\n\nAnd may include the following functions:\n\nsetup_all(cls)\n Setup fixture run before the first request.\n\nteardown_all(cls)\n Teardown fixture run after the last request.\n\nsetup_each(inst)\n Setup fixture run before each request.\n\nteardown_each(inst)\n Teardown fixture run after each request.\n\nTests in a trestle document consist of a ``.. request`` directive, followed by\none or more ``.. response`` directives. The ``.. request`` directive defines\nthe request to be sent to the web app under test, using the client defined in\nthe fixtures module.\n \nA simple request directive looks like this::\n\n .. request:: A simple get\n\n GET /foo/bar\n ..\n\nIf the request is a POST or PUT that includes data to be sent, include\nthat data in the body of the request, after the request line::\n\n .. request:: A post\n\n POST /foo/bar\n a=1&b=2\n ..\n\nThe response expected to be returned to the client is defined using a\nresponse block::\n\n .. response::\n\n Ponies!!1!\n ..\n\n\n.. note:: Conclude each block with ``..`` alone on a line to avoid rst parsing\n errors that can result in text following a block being thrown away.\n\nThe testing process is simple: each request is executed using the\nclient defined in the fixtures module, and each expected response\nfollowing that request in the text is compared against the actual\nresponse. If all responses match, the test passes. Otherwise, it\nfails.\n\n.. raw:: html\n\n

Passing examples are given a pleasing green \n background, failures a sinister red. \n Details of the failed match are included following the\n failed example.

\n\n\nFixture commands\n^^^^^^^^^^^^^^^^\n\nAt times it may be necessary to execute a unique fixture before executing a\nrequest. While it's usually better to make the test depend only on public apis\nand not internal details or externalities, sometimes (e.g. when testing\ntime-dependent operations) that isn't possible or reasonable. For those times,\nuse the **:setup:** argument to the request. The body of the exec argument\nwill be evaluated in the context of the fixture module before running the\nrequest. Naturally, there is also a **:teardown:** argument, which will be\nexecuted after the request is run and the response processed. Here's an\nexample::\n\n .. request:: Get something special\n :setup: client.set_special(true)\n :teardown: client.set_special(false)\n\n GET /special\n ..\n\n \nShell examples\n^^^^^^^^^^^^^^\n \nTrestle also supports shell examples. When a shell example is executed, the\nshell command given is executed, and the stdout produced by the command is\ncompared to the body of the ``..shell`` example using the normal doctest\noutput checker. A simple shell example looks like this::\n\n .. shell :: echo \"Hello\"\n\n Hello\n ..\n\nShell examples support the standard ``:setup:`` and ``:teardown`` options, as\nwell as three others: ``:cwd:``, which can be used to set the cwd of the shell\ncommand; ``:post:``, which names a fixture callable to be used to post-process\nthe output of the shell command before checking it against the expected\noutput, and the flag ``:stderr:``, which indicates that the example output\nshould be compared against the stderr output of the shell command, rather than\nstdout (which is the default).\n \n.. _`reStructured Text`: http://docutils.sourceforge.net/rst.html\n.. _`paste.fixtures.TestApp` : http://pythonpaste.org/testing-applications.html", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.google.com/p/nose-trestle/", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "trestle", "package_url": "https://pypi.org/project/trestle/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/trestle/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://code.google.com/p/nose-trestle/" }, "release_url": "https://pypi.org/project/trestle/0.2/", "requires_dist": null, "requires_python": null, "summary": "Trestle: doctest for ReST(ful services)", "version": "0.2" }, "last_serial": 638988, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8e0cf5f0d9ad436de623c2a024ac4e3a", "sha256": "477c715c397938849827ac21aa73a9c666dd2e3c047093111059f01f18994d8e" }, "downloads": -1, "filename": "trestle-0.1.tar.gz", "has_sig": false, "md5_digest": "8e0cf5f0d9ad436de623c2a024ac4e3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31580, "upload_time": "2008-03-14T20:15:52", "url": "https://files.pythonhosted.org/packages/e1/c8/2607a7f5da832639864b0387c93ae281d97779883aba2521b33e2014438e/trestle-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "832ee97d0c18ab56f1bfd7266eaa8c1e", "sha256": "417c94e53e5938d8c0bc8173b94b44cde37da8d147db78b07eb1b4a15c40c4ed" }, "downloads": -1, "filename": "trestle-0.2.tar.gz", "has_sig": false, "md5_digest": "832ee97d0c18ab56f1bfd7266eaa8c1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30402, "upload_time": "2009-06-02T18:42:35", "url": "https://files.pythonhosted.org/packages/ee/19/568b3bc9c1896fabb1aba26204d30e30dca68e700ca353ee7b49283323f4/trestle-0.2.tar.gz" } ], "0.2a1": [ { "comment_text": "", "digests": { "md5": "caa9eed7c81499a1b6227e6d147dbb28", "sha256": "2726163ec3efe7ab294eb3d12ef30befa3e0336da29f003be87812db59ca5a1a" }, "downloads": -1, "filename": "trestle-0.2a1-py2.5.egg", "has_sig": false, "md5_digest": "caa9eed7c81499a1b6227e6d147dbb28", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 36342, "upload_time": "2008-04-20T16:43:14", "url": "https://files.pythonhosted.org/packages/3a/89/046c9e26e0048850c8f55c7ae6690659142e5abc16c41f67daeaa9cc1016/trestle-0.2a1-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "3f509f8d57990138dc523b5bca7e5e9b", "sha256": "900e50190b68f3ffb822bb49012f7b0df76985932a2e199165ec685c47c87767" }, "downloads": -1, "filename": "trestle-0.2a1.tar.gz", "has_sig": false, "md5_digest": "3f509f8d57990138dc523b5bca7e5e9b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33592, "upload_time": "2008-04-20T16:43:03", "url": "https://files.pythonhosted.org/packages/9e/d9/4d7f3701ce6ba4059543eeb82ea27cdffba1262d36d01d07430ef0bc9788/trestle-0.2a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "832ee97d0c18ab56f1bfd7266eaa8c1e", "sha256": "417c94e53e5938d8c0bc8173b94b44cde37da8d147db78b07eb1b4a15c40c4ed" }, "downloads": -1, "filename": "trestle-0.2.tar.gz", "has_sig": false, "md5_digest": "832ee97d0c18ab56f1bfd7266eaa8c1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30402, "upload_time": "2009-06-02T18:42:35", "url": "https://files.pythonhosted.org/packages/ee/19/568b3bc9c1896fabb1aba26204d30e30dca68e700ca353ee7b49283323f4/trestle-0.2.tar.gz" } ] }