{ "info": { "author": "Joeri Bekker", "author_email": "joeri@maykinmedia.nl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development" ], "description": ".. image:: https://secure.travis-ci.org/joeribekker/restorm.png?branch=master\n :alt: Build Status\n :target: http://travis-ci.org/joeribekker/restorm\n\nRestORM\n=======\n\nRestORM allows you to interact with resources as if they were objects (object\nrelational mapping), mock an entire API and incorporate custom client logic.\n\nDescription\n-----------\n\nRestORM structures the way you access a RESTful API and allows you to easily\naccess related resources. It tries to be as generic as possible so it's not\ntailored to any specific API or server-side API library. With RestORM you can\nmock an entire API and replace the real client with a mock version in unit\ntests. RestORM is very extensible but offers many functionalities out of the box\nto get you up and running quickly.\n\nCurrently, RestORM works on Python 2.5+ with Python 3 support on its way.\n\nFeatures\n--------\n\n* Object relational mapping of API resources (Django-like but does not depend on\n Django at all).\n* Flexible client architecture that can be used with your own or third party\n clients (like oauth).\n* Extensive mocking module allows you to mock API responses, or even \n complete API's.\n* Examples for Twitter and Flickr API.\n\nQuick start\n===========\n\nThis is a compressed version of the tutorial. The full documentation can be \nfound `here `_.\n\nCreate a client\n---------------\n\nA typical client that can talk to a RESTful API using JSON, is no more then:\n\n.. sourcecode:: python\n\n from restorm.clients.jsonclient import JSONClient\n \n client = JSONClient(root_uri='http://www.example.com/api/')\n \nInstead of this client, we mock its intended behaviour.\n \nCreate a mock API\n-----------------\n\nIn order to test your client, you can emulate a whole API using the\n``MockApiClient`` and add pre-defined responses.\n\nThe mock API below contains a list of books and a list of authors. To keep it \nsimple, both list resources contain only 1 item:\n\n.. sourcecode:: python\n\n from restorm.clients.mockclient import MockApiClient\n \n mock_client = MockApiClient(\n responses={\n 'book/': {'GET': ({'Status': 200}, [{'isbn': 1, 'title': 'Dive into Python', 'resource_url': 'http://www.example.com/api/book/1'}])},\n 'book/1': {'GET': ({'Status': 200}, {'isbn': 1, 'title': 'Dive into Python', 'author': 'http://www.example.com/api/author/1'})},\n 'author/': {'GET': ({'Status': 200}, [{'id': 1, 'name': 'Mark Pilgrim', 'resource_url': 'http://www.example.com/author/1'}])},\n 'author/1': {'GET': ({'Status': 200}, {'id': 1, 'name': 'Mark Pilgrim'})}\n },\n root_uri='http://www.example.com/api/'\n )\n\nDefine resources\n----------------\n\nWe start with our main resource, the ``Book`` resource as a subclass of \n``Resource``. Two attributes in the inner ``Meta`` class indicate a URL-pattern\nhow we can access all books (``list``) and a single book (``item``):\n\n.. sourcecode:: python\n\n from restorm.resource import Resource\n\n class Book(Resource):\n class Meta:\n list = r'^book/$'\n item = r'^book/(?P\\d)$'\n\nBringing it all together\n------------------------\n\nYou can access the ``Book`` resource and the (runtime created) related \n``Author`` resource using the ``mock_client``:\n\n.. sourcecode:: python\n\n >>> book = Book.objects.get(isbn=1, client=mock_client) # Get book with ISBN number 1.\n >>> book.data['title'] # Get the value of the key \"name\".\n u'Dive into Python'\n >>> book.data['author'] # Get the value of the key \"author\".\n u'http://www.example.com/api/author/1'\n >>> author = book.data.author # Perform a GET on the \"author\" resource.\n >>> author.data['name']\n u'Mark Pilgrim'\n\nInstallation\n============\n\nRestORM is on PyPI, so you can simply use::\n\n $ pip install restorm\n\nIf you want the latest development version, get the code from Github::\n\n $ pip install -e git+git://github.com/joeribekker/restorm.git#egg=restorm\n\n\nChanges\n=======\n\n0.2\n---\n**December 4, 2012**\n\n- Fixed bug in ``MockClient`` to pop the correct response.\n- Added ``restorm.conf.settings`` to store the DEFAULT_CLIENT to use.\n- Added ability to create a development server from your ``MockApiClient``.\n- Added ``root_uri`` parameter to ``Client`` constructor.\n- Added initial XML client implemention (alpha).\n- Added initial documentation.\n- Added simplejson 2.2.1 or above as required library.\n\n0.1\n---\n**November 9, 2012**\n\n- Initial version released on PyPI.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/joeribekker/restorm", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "restorm", "package_url": "https://pypi.org/project/restorm/", "platform": "any", "project_url": "https://pypi.org/project/restorm/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/joeribekker/restorm" }, "release_url": "https://pypi.org/project/restorm/0.2/", "requires_dist": null, "requires_python": null, "summary": "RestORM allows you to interact with resources as if they were objects.", "version": "0.2" }, "last_serial": 798915, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3a36be3939e0129a33df3ad9e68f275a", "sha256": "9a6b2511750d4ea3afb8b7645603334540d6884b4ac4b3df66e56bc09402f27f" }, "downloads": -1, "filename": "restorm-0.1.tar.gz", "has_sig": false, "md5_digest": "3a36be3939e0129a33df3ad9e68f275a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23641, "upload_time": "2012-11-09T09:53:31", "url": "https://files.pythonhosted.org/packages/00/9d/9938841aac72a1c3f1c8feba8fc48ba1975d8e68865d18a72afd1e4ffc21/restorm-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "5e6fefacd4419513ef3d8d9621a9a447", "sha256": "f959003a1c088c2cb1f5b27b7390ac173316ae39df1b4f06bc6d678c61c91a9b" }, "downloads": -1, "filename": "restorm-0.2.tar.gz", "has_sig": false, "md5_digest": "5e6fefacd4419513ef3d8d9621a9a447", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28919, "upload_time": "2012-12-06T14:49:33", "url": "https://files.pythonhosted.org/packages/aa/5e/bc2c6d0f7eebd141d4788cb8e99f18ac2877e6381e96bda9e47ed454ee2c/restorm-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5e6fefacd4419513ef3d8d9621a9a447", "sha256": "f959003a1c088c2cb1f5b27b7390ac173316ae39df1b4f06bc6d678c61c91a9b" }, "downloads": -1, "filename": "restorm-0.2.tar.gz", "has_sig": false, "md5_digest": "5e6fefacd4419513ef3d8d9621a9a447", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28919, "upload_time": "2012-12-06T14:49:33", "url": "https://files.pythonhosted.org/packages/aa/5e/bc2c6d0f7eebd141d4788cb8e99f18ac2877e6381e96bda9e47ed454ee2c/restorm-0.2.tar.gz" } ] }