model-bakery


Namemodel-bakery JSON
Version 1.20.0 PyPI version JSON
download
home_pageNone
SummarySmart object creation facility for Django.
upload_time2024-10-10 08:12:08
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/31/2d/9f61b529c788b367a6bac5b211bf8879036b4bcb27a5e9e78808131ea6fb/model_bakery-1.20.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.20.0",
    "project_urls": {
        "Homepage": "https://github.com/model-bakers/model_bakery"
    },
    "split_keywords": [
        "django",
        " factory",
        " python",
        " testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60f0c6a6c8ac6fd1dd3c0241ac69230af6592e573d3dedc2ff95b22a352c10f2",
                "md5": "b9f6ca5b3fada12907f6257e8e3f6d8d",
                "sha256": "875326466f5982ee8f0281abdfa774d78893d5473562575dfd5a9304ac7c5b8c"
            },
            "downloads": -1,
            "filename": "model_bakery-1.20.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b9f6ca5b3fada12907f6257e8e3f6d8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 24019,
            "upload_time": "2024-10-10T08:12:06",
            "upload_time_iso_8601": "2024-10-10T08:12:06.910053Z",
            "url": "https://files.pythonhosted.org/packages/60/f0/c6a6c8ac6fd1dd3c0241ac69230af6592e573d3dedc2ff95b22a352c10f2/model_bakery-1.20.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "312d9f61b529c788b367a6bac5b211bf8879036b4bcb27a5e9e78808131ea6fb",
                "md5": "3a33d6130369391c7c335950d86e2f07",
                "sha256": "ec9dc846b9a00b20f92df38fac310263323ab61b59b6eeebf77a4aefb0412724"
            },
            "downloads": -1,
            "filename": "model_bakery-1.20.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3a33d6130369391c7c335950d86e2f07",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21016,
            "upload_time": "2024-10-10T08:12:08",
            "upload_time_iso_8601": "2024-10-10T08:12:08.254105Z",
            "url": "https://files.pythonhosted.org/packages/31/2d/9f61b529c788b367a6bac5b211bf8879036b4bcb27a5e9e78808131ea6fb/model_bakery-1.20.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-10 08:12:08",
    "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.42473s