Skip to main content

Mimesis integration with factory_boy

Project description

mimesis_factory

Build Status Coverage PyPI version wemake-python-styleguide

Description

Mimesis integration for factory_boy.

Installation

  pip install mimesis_factory

Usage

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

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

Now, use the MimesisField class from mimesis_factory to define how fake data is generated:

import factory
from mimesis_factory import MimesisField

from account import Account


class AccountFactory(factory.Factory):
    class Meta(object):
        model = Account

    username = MimesisField('username', template='l_d')
    name = MimesisField('name', gender='female')
    surname = MimesisField('surname', gender='female')
    age = MimesisField('age', minimum=18, maximum=90)
    email = factory.LazyAttribute(
        lambda instance: '{0}@example.org'.format(instance.username)
    )
    access_token = MimesisField('token', entropy=32)

pytest

We also recommend to use pytest-factoryboy. This way it will be possible to integrate your factories into pytest fixtures.

License

mimesis_factory is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mimesis_factory-1.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

mimesis_factory-1.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file mimesis_factory-1.1.0.tar.gz.

File metadata

  • Download URL: mimesis_factory-1.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.4 CPython/3.7.2 Darwin/18.6.0

File hashes

Hashes for mimesis_factory-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a4a6aee378ef72a1de2809cba11689d485928d981203815408110c45bdd3cfab
MD5 7b8b907c676a350febd6775cabf1d980
BLAKE2b-256 efea9d8d612fb72b4385380e056e38cb32d0ee25f90930d25e6c2d0936ca9aaf

See more details on using hashes here.

File details

Details for the file mimesis_factory-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mimesis_factory-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.4 CPython/3.7.2 Darwin/18.6.0

File hashes

Hashes for mimesis_factory-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05018b1aac7390e9f5d1ec0591a30ef9bf2908f80fd7f6c1f486d14122e9cfa2
MD5 8dfd72c9d1c2b94f3b9c3c9b38068383
BLAKE2b-256 cc1a4ca2502c4e1686acaa4858130c9d35c6ba50b9ec51c61206f71945d02879

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page