model-bakery


Namemodel-bakery JSON
Version 1.18.0 PyPI version JSON
download
home_pageNone
SummarySmart object creation facility for Django.
upload_time2024-04-21 15:04:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseApache License 2.0
keywords django factory python testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Model Bakery: Smart fixtures for better tests

[![Build](https://img.shields.io/github/actions/workflow/status/model-bakers/model_bakery/ci.yml?branch=main)](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)
[![Coverage](https://img.shields.io/badge/Coverage-97%25-success)](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)
[![Latest PyPI version](https://img.shields.io/pypi/v/model_bakery.svg)](https://pypi.python.org/pypi/model_bakery/)
[![Documentation Status](https://readthedocs.org/projects/model-bakery/badge/?version=latest)](https://model-bakery.readthedocs.io/en/latest/?badge=latest)

*Model Bakery* offers you a smart way to create fixtures for testing in
Django.
With a simple and powerful API you can create many objects with a single
line of code.

Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).

## Install

```bash
pip install model-bakery
```

## Usage and Info

### Basic usage

```python

# models.py

from django.db import models

class Customer(models.Model):
    enjoy_jards_macale = models.BooleanField()
    name = models.CharField(max_length=30)
    email = models.EmailField()
    age = models.IntegerField()
    bio = models.TextField()
    days_since_last_login = models.BigIntegerField()
    birthday = models.DateField()
    last_shopping = models.DateTimeField()

# test_models.py

from django.test import TestCase
from model_bakery import baker
from pprint import pprint

class TestCustomerModel(TestCase):
    def setUp(self):
        self.customer = baker.make('shop.Customer')
        pprint(self.customer.__dict__)

"""
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
 'age': 3841,
 'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
 'birthday': datetime.date(2019, 12, 3),
 'enjoy_jards_macale': True,
 'id': 1,
 'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',
 'days_since_last_login': 6016}
"""

```

Check out [documentation](<http://model-bakery.readthedocs.org/>) for more complete examples.

## Contributing

Detailed info [here](https://github.com/model-bakers/model_bakery/blob/main/CONTRIBUTING.md).

## Maintainers

  - [Bernardo Fontes](https://github.com/berinhard/)
  - [Rustem Saiargaliev](https://github.com/amureki/)
  - [Tim Klein](https://github.com/timjklein36)

## Creator

  - [Vanderson Mota](https://github.com/vandersonmota/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "model-bakery",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django, factory, python, testing",
    "author": null,
    "author_email": "berin <bernardoxhc@gmail.com>, amureki <amureki@hey.com>",
    "download_url": "https://files.pythonhosted.org/packages/55/69/bdf979b2f2e05c1604b5b6bb48c2967a8fd25b8be9c1e22d8f942c410ccf/model_bakery-1.18.0.tar.gz",
    "platform": null,
    "description": "# Model Bakery: Smart fixtures for better tests\n\n[![Build](https://img.shields.io/github/actions/workflow/status/model-bakers/model_bakery/ci.yml?branch=main)](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)\n[![Coverage](https://img.shields.io/badge/Coverage-97%25-success)](https://github.com/model-bakers/model_bakery/actions?workflow=Tests)\n[![Latest PyPI version](https://img.shields.io/pypi/v/model_bakery.svg)](https://pypi.python.org/pypi/model_bakery/)\n[![Documentation Status](https://readthedocs.org/projects/model-bakery/badge/?version=latest)](https://model-bakery.readthedocs.io/en/latest/?badge=latest)\n\n*Model Bakery* offers you a smart way to create fixtures for testing in\nDjango.\nWith a simple and powerful API you can create many objects with a single\nline of code.\n\nModel Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).\n\n## Install\n\n```bash\npip install model-bakery\n```\n\n## Usage and Info\n\n### Basic usage\n\n```python\n\n# models.py\n\nfrom django.db import models\n\nclass Customer(models.Model):\n    enjoy_jards_macale = models.BooleanField()\n    name = models.CharField(max_length=30)\n    email = models.EmailField()\n    age = models.IntegerField()\n    bio = models.TextField()\n    days_since_last_login = models.BigIntegerField()\n    birthday = models.DateField()\n    last_shopping = models.DateTimeField()\n\n# test_models.py\n\nfrom django.test import TestCase\nfrom model_bakery import baker\nfrom pprint import pprint\n\nclass TestCustomerModel(TestCase):\n    def setUp(self):\n        self.customer = baker.make('shop.Customer')\n        pprint(self.customer.__dict__)\n\n\"\"\"\n{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,\n 'age': 3841,\n 'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',\n 'birthday': datetime.date(2019, 12, 3),\n 'enjoy_jards_macale': True,\n 'id': 1,\n 'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),\n 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',\n 'days_since_last_login': 6016}\n\"\"\"\n\n```\n\nCheck out [documentation](<http://model-bakery.readthedocs.org/>) for more complete examples.\n\n## Contributing\n\nDetailed info [here](https://github.com/model-bakers/model_bakery/blob/main/CONTRIBUTING.md).\n\n## Maintainers\n\n  - [Bernardo Fontes](https://github.com/berinhard/)\n  - [Rustem Saiargaliev](https://github.com/amureki/)\n  - [Tim Klein](https://github.com/timjklein36)\n\n## Creator\n\n  - [Vanderson Mota](https://github.com/vandersonmota/)\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Smart object creation facility for Django.",
    "version": "1.18.0",
    "project_urls": {
        "Homepage": "https://github.com/model-bakers/model_bakery"
    },
    "split_keywords": [
        "django",
        " factory",
        " python",
        " testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38aec4be67a1c0e1fd6c5ce37de893db8ff5c1c33228b0d4952deb7e9108770a",
                "md5": "e6e5d8a99edc08d9fd9c8582b0565b67",
                "sha256": "c894ecea99d4b24a790c10f02140f695130cdba13e834296263e542e543b32ed"
            },
            "downloads": -1,
            "filename": "model_bakery-1.18.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6e5d8a99edc08d9fd9c8582b0565b67",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 23378,
            "upload_time": "2024-04-21T15:04:40",
            "upload_time_iso_8601": "2024-04-21T15:04:40.278527Z",
            "url": "https://files.pythonhosted.org/packages/38/ae/c4be67a1c0e1fd6c5ce37de893db8ff5c1c33228b0d4952deb7e9108770a/model_bakery-1.18.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5569bdf979b2f2e05c1604b5b6bb48c2967a8fd25b8be9c1e22d8f942c410ccf",
                "md5": "da7391e9e597e29c5606af362c96dda5",
                "sha256": "d44c36ea9891323c5c5eaa62224a2bc4daa9f5c31facdd54715d5d89ab6fbdb4"
            },
            "downloads": -1,
            "filename": "model_bakery-1.18.0.tar.gz",
            "has_sig": false,
            "md5_digest": "da7391e9e597e29c5606af362c96dda5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20400,
            "upload_time": "2024-04-21T15:04:42",
            "upload_time_iso_8601": "2024-04-21T15:04:42.147460Z",
            "url": "https://files.pythonhosted.org/packages/55/69/bdf979b2f2e05c1604b5b6bb48c2967a8fd25b8be9c1e22d8f942c410ccf/model_bakery-1.18.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 15:04:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "model-bakers",
    "github_project": "model_bakery",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "model-bakery"
}
        
Elapsed time: 0.25993s