{ "info": { "author": "Adam Venturella", "author_email": "aventurella@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Mockingbird\n\n**Your models, mock data**\n\n[![Build Status](https://secure.travis-ci.org/aventurella/mockingbird.png?branch=master)](http://travis-ci.org/aventurella/mockingbird)\n\nMockingbird creates mock data for your models. It keeps your front-end\ndevs happy, they can work with the output and not need to talk to a database.\n\nIt is **not** related to [http://pypi.python.org/pypi/mock/](http://pypi.python.org/pypi/mock/)\n\nIf you are setting up your application like this, it can be a very powerful\ntool to keep your front end dev marking-it-up™ and stylin-it-up™\n\n```python\n\nclass SqlContactRepository(object):\n def get_contact(self):\n \"\"\"\n this method is not done yet, but it would be really great\n for the my front end developers start working and not wait on me.\n I will use the MockContactRepository for the time being\n while I work here. Maybe I will fetch Django Models or some other\n custom work... Who knows! While I figure it out though no need\n to make my front end wait!\n \"\"\"\n pass\n\nclass MockContactRepository(object)\n def get_contact(self):\n return mockingbird.Contact()\n\n\nclass ContactService(object):\n def __init__(self, dao):\n self.dao = dao\n\n def get_contact(self):\n return self.dao.get_contact()\n\n\nclass MyController(MyControllerBase):\n def some_action(self):\n service = ContactService(MockContacts)\n contacts = service.get_contact()\n```\n\nI would even go one step further and not even define the service in the\ncontroller, but define all of the services for your app in say...\n\n[http://github.com/aventurella/pydi](http://github.com/aventurella/pydi)\n\nThen you can control all of your service dependencies from one location!\nWith the flip of some text all of your services could deliver\nmock data or real data and your front end devs never need know the difference!\n\n**Mockingbird! Your models, mock data Shaaaaaaaaaaa!**\n\n## Setup\n\nFirst make some models. I'm just going to use plain-ol-python-objects.\nYou should be able to use any kind of model you like, Django, SQLAlchemy, etc\nthough those are untested.\n\nMockingbird uses ```setattr(your_model, \"attribute_name\", value)```. So anything\nthat supports that should work.\n\n```python\nclass Contact(object):\n def __init__(self):\n self.name = None\n self.label = None\n self.meta = None\n\n\nclass ContactMeta(object):\n def __init__(self):\n self.phone = None\n self.email = None\n self.dob = None,\n self.age = 0\n self.is_married = False\n\n\nclass AddressBook(object):\n def __init__(self):\n self.contacts = []\n```\n\nNow that we have some models, lets tell Mockingbird about them:\n\n```python\n\nfrom mockingbird import Mockingbird\n\nmockingbird = Mockingbird()\nmockingbird.spec(Contact, {\"name\": MockRealName(),\n \"label\": MockString(min=4, max=10),\n \"meta\": MockObject(ContactMeta)})\n\nmockingbird.spec(ContactMeta, {\"phone\": MockPhone(),\n \"email\": MockEmail(),\n \"dob\": MockDate(),\n \"age\": MockInt(min=22, max=44)\n \"is_married\": MockBoolean()})\n\nmockingbird.spec(AddressBook, {\"contacts\": MockList(Contact, min=10, max=20)})\n\n```\n\nAs you can see, we let Mockingbird know the class we would like to register\nand the attributes we would like it to set. In the dictionary that is passed\nthe keys represent the attributes and the values represent the kind of mock data\nwe would like to have applied.\n\nNow to get one of our models filled up with mock data:\n\n```python\n\ncontact = mockingbird.Contact()\nbook = mockingbird.AddressBook()\n\nprint(contact.meta.__dict__)\nprint(book.contacts)\nprint(book.contacts[0].meta.__dict__)\n```\n\nTa da! model objects filled to the brim with fake data. Let your front end devs\ngo nuts while you work on the server logic.\n\nCurrently Mockingbird supports the following Mock Data Generators:\n\n- MockBoolean\n- MockChoice\n- MockDate\n- MockEmail\n- MockInt\n- MockList\n- MockObject\n- MockPhoneNumber\n- MockRealName\n- MockText\n\nIf you would like to see how their used, go ahead and look at tests/test_generators.py\nfor now until I can write up the docs on their options. Or browse through ```mockingbird.generators.*```\n\nHere are some additional generators I am thinking about adding:\n\n- MockAddress\n- MockCity\n- MockHash\n- MockPrice\n- MockState\n- MockUsername\n- MockZip", "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/aventurella/mockingbird", "keywords": null, "license": "Copyright (c) 2012 Adam Venturella.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "mockingbird", "package_url": "https://pypi.org/project/mockingbird/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mockingbird/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/aventurella/mockingbird" }, "release_url": "https://pypi.org/project/mockingbird/0.1.4/", "requires_dist": null, "requires_python": null, "summary": "Your models, fake data", "version": "0.1.4" }, "last_serial": 794891, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2e49c741a8ba491e7b891e9f1dcbec47", "sha256": "665aae1c0da633767c2e7a08e6f941c13fc2955931d88353e476bd116fb3b711" }, "downloads": -1, "filename": "mockingbird-0.1.tar.gz", "has_sig": false, "md5_digest": "2e49c741a8ba491e7b891e9f1dcbec47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5180, "upload_time": "2012-09-23T16:26:29", "url": "https://files.pythonhosted.org/packages/01/00/ac3a4150046271fef9c9e2d8c2e700d2878260097cdf6c10c18fa36d9694/mockingbird-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7a2e265975a55316b437abb573c994a9", "sha256": "ed0dea81dacf8f1ef86f03476baed5f09e3002c076988981fe0d628a30e8fa7a" }, "downloads": -1, "filename": "mockingbird-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7a2e265975a55316b437abb573c994a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8553, "upload_time": "2012-09-24T05:08:35", "url": "https://files.pythonhosted.org/packages/ab/81/d413b41ab10574693385b90ac95f6ef80e07de55c30240da9d517e20d096/mockingbird-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "85d7109150a9483e6421c5f86eab36ca", "sha256": "30e04b1b1fdba9201b7cd60915661050036db0a3676ea905e657b6d4e9dd3d46" }, "downloads": -1, "filename": "mockingbird-0.1.2.tar.gz", "has_sig": false, "md5_digest": "85d7109150a9483e6421c5f86eab36ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8581, "upload_time": "2012-09-24T05:20:40", "url": "https://files.pythonhosted.org/packages/42/3b/986af0bee2eec6bd7a12ed54ca1afc6f4ca41bdc7f9d118c6275ca2fbac9/mockingbird-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "c2dc3905a75e97a23ce4ea865363fb4e", "sha256": "2276f05dfeced244b3a782be9a1be9c336f4230b6af1ace1305ed893d9d7fe65" }, "downloads": -1, "filename": "mockingbird-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c2dc3905a75e97a23ce4ea865363fb4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8586, "upload_time": "2012-09-24T05:24:56", "url": "https://files.pythonhosted.org/packages/52/80/d91e25cd396dc24e8a9aca509b6985edbefe6db0bfff29281d39a23420d7/mockingbird-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "a280533cb81e1a0ad8915545e87a4971", "sha256": "66c2676af92bd57e8e8f18d78924812e508ee2b164a592a58cf945dff525954b" }, "downloads": -1, "filename": "mockingbird-0.1.4.tar.gz", "has_sig": false, "md5_digest": "a280533cb81e1a0ad8915545e87a4971", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13234, "upload_time": "2012-09-24T05:28:12", "url": "https://files.pythonhosted.org/packages/ae/12/56cc732810cb55e410a316dd2bb732a62f9f2b1e8f874f7fc7b19f1af450/mockingbird-0.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a280533cb81e1a0ad8915545e87a4971", "sha256": "66c2676af92bd57e8e8f18d78924812e508ee2b164a592a58cf945dff525954b" }, "downloads": -1, "filename": "mockingbird-0.1.4.tar.gz", "has_sig": false, "md5_digest": "a280533cb81e1a0ad8915545e87a4971", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13234, "upload_time": "2012-09-24T05:28:12", "url": "https://files.pythonhosted.org/packages/ae/12/56cc732810cb55e410a316dd2bb732a62f9f2b1e8f874f7fc7b19f1af450/mockingbird-0.1.4.tar.gz" } ] }