Skip to content

casio/mimesis-factory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mimesis_factory

Python PyPI version

Description

Mimesis integration with factory_boy.

Installation

pip install mimesis_factory

Usage

Just look at the example below and you’ll understand how it works:

import datetime
import random

class Account(object):
    def __init__(self, username, email, name, surname, age):
        self.username = username
        self.email = email
        self.name = name
        self.surname = surname
        self.age = age
        self.password = ''.join(str(random.randint(0, 10)) for _ in range(10))
        self.date_joined = datetime.datetime.today()

    def __str__(self):
        return '{} ({})'.format(self.username, self.email)

Simply use the Mimesis class from mimesis_factory:

import factory
from mimesis_factory import Mimesis

from account import Account

class AccountFactory(factory.Factory):
    class Meta:
        model = Account
        
    username = Mimesis('username', template='l_d')
    name = Mimesis('name', gender='female')
    surname = Mimesis('surname', gender='female')
    age = Mimesis('age', minimum=18, maximum=28)
    email = factory.LazyAttribute(
        lambda o: '%[email protected]' % o.username
    )
    access_token = Mimesis('token', entropy=32)

License

mimesis_factory is released under the MIT License.

About

Mimesis integration with factory_boy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%