{ "info": { "author": "Ben Bangert", "author_email": "ben@groovie.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Testing" ], "description": "======\nDalton\n======\n\n\"I want you to be nice, until it's time to not be nice.\"\n -- Dalton, Road-House\n\nAn httplib injection library for recording and playing back HTTP interactions.\n\nDalton monkey-patches two methods of httplib's HTTPConnection class to\nintercept request/response interactions, and can play them back based on a\nDalton recording. To ease testing, the recording is generated Python code to\nease in customization of the response and to allow for branches in the\nplayback path.\n\nMonkey-patched methods of HTTPConnection:\n - request\n - getresponse\n\nUsing the more verbose method to send/recieve requests with HTTPConnection is\nnot supported at this time.\n\n**Note:** This is a first and early release, mainly so that I could use it\nwith mechanize to record/playback interactions. As mechanize only uses the\nrequest/getresponse API on HTTPConnection, I have no interest in adding\nintercept to the rest. Please feel free to fork this to add additional\nfeatures as I don't plan on adding them myself (though I will happily pull bug\nfixes and feature additions with unit tests).\n\n**Warning:** Dalton uses ``inspect.currentframe`` magic to derive the caller\nwhich may only work on CPython (PyPy and Jython is untested).\n\n\nExample\n=======\n\nSince dalton monkey-patches httplib, no modification is necessary of libraries\nthat utilize the supported methods.\n\n::\n\n import dalton\n dalton.inject() # monkey-patch httplib\n \n from httplib import HTTPConnection\n h = HTTPConnection('www.google.com')\n \n # when recording, httplib capture is restricted by caller\n recorder = dalton.Recorder(caller=h)\n \n # record httplib calls in this block\n with recorder.recording():\n h.request('GET', '/')\n resp = h.getresponse()\n body = resp.read()\n \n # save the interaction\n recorder.save('google')\n\nA folder called ``google`` will be created in the current directory for use\nwith dalton's playback facility.\n\nPlaying it back::\n \n import dalton\n dalton.inject() # monkey-patch httplib\n \n from httplib import HTTPConnection\n h = HTTPConnection('www.google.com')\n \n # load the player\n player = dalton.Player(caller=h, playback_dir='google')\n \n # run httplib calls against the player\n with player.playing():\n h.request('GET', '/')\n resp = h.getresponse()\n body = resp.read()\n \n # body is now the same as it was recorded, no calls to www.google.com\n # were made\n\nThis generates a directory ``google`` with the following layout:\n - ``__init__.py``\n - ``step_0_response.txt``\n\nThe contents of ``__init__.py`` contain the following generated playback\ninformation::\n \n import os\n import dalton\n from dalton import FileWrapper\n\n here = os.path.abspath(os.path.dirname(__file__))\n\n class StepNumber0(object):\n recorded_request = {\n 'headers': {},\n 'url': '/',\n 'method': 'GET',\n 'body': None,\n }\n recorded_response = {\n 'headers': [('x-xss-protection', '1; mode=block'),\n ('transfer-encoding', 'chunked'),\n ( 'set-cookie',\n 'PREF=ID=ff; expires=Thu, 11-Apr-2013 20:19:35 GMT; path=/; domain=.google.com, NID=45=fU; expires=Wed, 12-Oct-2011 20:19:35 GMT; path=/; domain=.google.com; HttpOnly'),\n ('expires', '-1'),\n ('server', 'gws'),\n ('cache-control', 'private, max-age=0'),\n ('date', 'Tue, 12 Apr 2011 20:19:35 GMT'),\n ('content-type', 'text/html; charset=ISO-8859-1')],\n 'body': FileWrapper('step_0_response.txt', here),\n 'status': 200,\n 'reason': 'OK',\n 'version': 11,\n }\n next_step = 'None'\n\n def handle_request(self, request):\n assert dalton.request_match(request, self.recorded_request)\n return (self.next_step, dalton.create_response(self.recorded_response))\n\nThis file can be modified after recordings to customize the playback, add\nadditional branches, etc.\n\nSupport\n=======\n\nDalton is considered feature-complete as the project owner (Ben Bangert) has\nno additional functionality or development beyond bug fixes planned. Bugs can\nbe filed on github, should be accompanied by a test case to retain current\ncode coverage, and should be in a Pull request when ready to be accepted into\nthe Dalton code-base.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bbangert/Dalton", "keywords": "mechanize httplib crawling mock test", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "dalton", "package_url": "https://pypi.org/project/dalton/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dalton/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/bbangert/Dalton" }, "release_url": "https://pypi.org/project/dalton/1.0/", "requires_dist": null, "requires_python": null, "summary": "An httplib injection library for recording and playing back HTTP interactions.", "version": "1.0" }, "last_serial": 788766, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "39754c6bfa24690facda8fb8bdd2041e", "sha256": "71c8d2248a4a7b50732a1dd90ec41afde0e3d3cbd5e1da7305e9ae2b7adcdc2c" }, "downloads": -1, "filename": "dalton-0.1.tar.gz", "has_sig": false, "md5_digest": "39754c6bfa24690facda8fb8bdd2041e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18635, "upload_time": "2011-04-12T22:36:35", "url": "https://files.pythonhosted.org/packages/7a/b0/857680140795084a0cb570c0d836af286c86d7d7dc0d664b31636b9b61f6/dalton-0.1.tar.gz" } ], "0.1dev": [], "0.2": [ { "comment_text": "", "digests": { "md5": "c508ca9f0f764c8818292dbb3729d6ab", "sha256": "2f3fd50c4075f32396b22d7ad0b2d42106cc6f988763f4791a675cd8512f931e" }, "downloads": -1, "filename": "dalton-0.2.tar.gz", "has_sig": false, "md5_digest": "c508ca9f0f764c8818292dbb3729d6ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18999, "upload_time": "2011-05-10T19:26:50", "url": "https://files.pythonhosted.org/packages/04/ee/6f9d994db4629b8cb46dffb437454127b7695e2b8c28acace650b959336a/dalton-0.2.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "660d7d1854a874cb681244e3c483aa48", "sha256": "96f35aca8718a3e472496237488e698aa025273385375cb3ddf2d89806ba10b6" }, "downloads": -1, "filename": "dalton-1.0.tar.gz", "has_sig": false, "md5_digest": "660d7d1854a874cb681244e3c483aa48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19251, "upload_time": "2011-10-16T01:17:15", "url": "https://files.pythonhosted.org/packages/9b/36/b8535f2e5a354b3ae5e2c3e447f8503b7760d8c0e3859091fcc5a52fd53e/dalton-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "660d7d1854a874cb681244e3c483aa48", "sha256": "96f35aca8718a3e472496237488e698aa025273385375cb3ddf2d89806ba10b6" }, "downloads": -1, "filename": "dalton-1.0.tar.gz", "has_sig": false, "md5_digest": "660d7d1854a874cb681244e3c483aa48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19251, "upload_time": "2011-10-16T01:17:15", "url": "https://files.pythonhosted.org/packages/9b/36/b8535f2e5a354b3ae5e2c3e447f8503b7760d8c0e3859091fcc5a52fd53e/dalton-1.0.tar.gz" } ] }