def factory(model, **kwargs): """ Creates a factory boy factory class """ ns = {'Meta': type('Meta', (), {'model': model})} # Handle explicitly declared values for k, v in kwargs: ns[k] = explicit_declaration(model, k, v) # Create mommy instance to help with automatic value generation mommy = Mommy(model) # Create implicit declarations for field in model._meta.fields: if not requires_declaration(model, field.name, ns): continue ns[field.name] = implicit_declaration(model, field.name, ns, mommy) return type(model.__name__ + 'Factory', (BoogieFactory, ), ns)
def exist_a_project(step): for project_hashes in step.hashes: mom = Mommy(Project, False) project = mom.make_one(name=project_hashes.get('name'))
def exist_a_news(step): for news_hashes in step.hashes: mom = Mommy(News, False) news = mom.make_one(title=news_hashes.get('title'), summary=news_hashes.get('summary'))
def exist_a_tool(step): for tool_hashes in step.hashes: mom = Mommy(Tool, False) tool = mom.make_one(name=tool_hashes.get('name'), highlight=tool_hashes.get('highlight'))