This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# Mockingbird

**Your models, mock data**

[![Build Status](https://secure.travis-ci.org/aventurella/mockingbird.png?branch=master)](http://travis-ci.org/aventurella/mockingbird)

Mockingbird creates mock data for your models. It keeps your front-end
devs happy, they can work with the output and not need to talk to a database.

It is **not** related to [http://pypi.python.org/pypi/mock/](http://pypi.python.org/pypi/mock/)

If you are setting up your application like this, it can be a very powerful
tool to keep your front end dev marking-it-up™ and stylin-it-up™

```python

class SqlContactRepository(object):
def get_contact(self):
"""
this method is not done yet, but it would be really great
for the my front end developers start working and not wait on me.
I will use the MockContactRepository for the time being
while I work here. Maybe I will fetch Django Models or some other
custom work... Who knows! While I figure it out though no need
to make my front end wait!
"""
pass

class MockContactRepository(object)
def get_contact(self):
return mockingbird.Contact()


class ContactService(object):
def __init__(self, dao):
self.dao = dao

def get_contact(self):
return self.dao.get_contact()


class MyController(MyControllerBase):
def some_action(self):
service = ContactService(MockContacts)
contacts = service.get_contact()
```

I would even go one step further and not even define the service in the
controller, but define all of the services for your app in say...

[http://github.com/aventurella/pydi](http://github.com/aventurella/pydi)

Then you can control all of your service dependencies from one location!
With the flip of some text all of your services could deliver
mock data or real data and your front end devs never need know the difference!

**Mockingbird! Your models, mock data Shaaaaaaaaaaa!**

## Setup

First make some models. I'm just going to use plain-ol-python-objects.
You should be able to use any kind of model you like, Django, SQLAlchemy, etc
though those are untested.

Mockingbird uses ```setattr(your_model, "attribute_name", value)```. So anything
that supports that should work.

```python
class Contact(object):
def __init__(self):
self.name = None
self.label = None
self.meta = None


class ContactMeta(object):
def __init__(self):
self.phone = None
self.email = None
self.dob = None,
self.age = 0
self.is_married = False


class AddressBook(object):
def __init__(self):
self.contacts = []
```

Now that we have some models, lets tell Mockingbird about them:

```python

from mockingbird import Mockingbird

mockingbird = Mockingbird()
mockingbird.spec(Contact, {"name": MockRealName(),
"label": MockString(min=4, max=10),
"meta": MockObject(ContactMeta)})

mockingbird.spec(ContactMeta, {"phone": MockPhone(),
"email": MockEmail(),
"dob": MockDate(),
"age": MockInt(min=22, max=44)
"is_married": MockBoolean()})

mockingbird.spec(AddressBook, {"contacts": MockList(Contact, min=10, max=20)})

```

As you can see, we let Mockingbird know the class we would like to register
and the attributes we would like it to set. In the dictionary that is passed
the keys represent the attributes and the values represent the kind of mock data
we would like to have applied.

Now to get one of our models filled up with mock data:

```python

contact = mockingbird.Contact()
book = mockingbird.AddressBook()

print(contact.meta.__dict__)
print(book.contacts)
print(book.contacts[0].meta.__dict__)
```

Ta da! model objects filled to the brim with fake data. Let your front end devs
go nuts while you work on the server logic.

Currently Mockingbird supports the following Mock Data Generators:

- MockBoolean
- MockChoice
- MockDate
- MockEmail
- MockInt
- MockList
- MockObject
- MockPhoneNumber
- MockRealName
- MockText

If you would like to see how their used, go ahead and look at tests/test_generators.py
for now until I can write up the docs on their options. Or browse through ```mockingbird.generators.*```

Here are some additional generators I am thinking about adding:

- MockAddress
- MockCity
- MockHash
- MockPrice
- MockState
- MockUsername
- MockZip
Release History

Release History

0.1.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
mockingbird-0.1.4.tar.gz (13.2 kB) Copy SHA256 Checksum SHA256 Source Sep 24, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting