Skip to content

anentropic/factoryboy-gaendb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

factoryboy-gaendb

Factoryboy base factories and helpers for Google App Engine ndb models

Example:

from gaendb.factories import NDBFactory, KeyAttribute

class UserFactory(NDBFactory):
    class Meta:
        model = User

    name = fuzzy.FuzzyText()
    gender = fuzzy.FuzzyChoice(['M', 'F'])

class ArticleFactory(NDBFactory):
    class Meta:
        model = Article

    author = KeyAttribute(UserFactory)
    title = fuzzy.FuzzyText()
In  [1]: article = ArticleFactory()  # build
In  [2]: article.author
Out [2]: Key('User', 1)
In  [3]: article.author.get()
Out [3]: User(key=Key('User', 1), gender='F', name=u'UvaxfhCjiwlg')  # built instance

Can set id and/or parent of the key when building:

In  [1]: article = ArticleFactory(id=27)
In  [2]: article.key
Out [2]: Key('Article', 27)

About

Factoryboy base factories and helpers for Google App Engine ndb models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages