Skip to main content

Simple library for creating fake models in the unit tests.

Project description

https://badge.fury.io/py/django-fake-model.png https://travis-ci.org/erm0l0v/django-fake-model.png?branch=master

Simple library for creating fake models in the unit tests.

This simple library allows to create fake models in your test without migrations, test apps and test tables in your base. All tables that you need will created/removed during the test.

Install

Install django-fake-model:

pip install django-fake-model

Quickstart

Just create a model in any file (Ex: in your test) and add decorator @YourModel.fake_me to test method or test class.

from django_fake_model import models as f
from django.db import models
from django.test import TestCase


class MyFakeModel(f.FakeModel):

    name = models.CharField(max_length=100)


@MyFakeModel.fake_me
class MyFakeModelTests(TestCase):

    def test_create_model(self):
        MyFakeModel.objects.create(name='123')
        model = MyFakeModel.objects.get(name='123')
        self.assertEqual(model.name, '123')


class MyFakeModelFunctionTest(TestCase):

    @MyFakeModel.fake_me
    def test_create_model(self):
        MyFakeModel.objects.create(name='123')
        model = MyFakeModel.objects.get(name='123')
        self.assertEqual(model.name, '123')

Cookiecutter Tools Used in Making This Package

  • cookiecutter

  • cookiecutter-djangopackage

History

0.1.0 (2015-09-16)

  • First release on PyPI.

0.1.1 (2015-09-28)

  • Added tests with different databases.

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

django-fake-model-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

django_fake_model-0.1.1-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-fake-model-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-fake-model-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5d72e7b278445556829e8108fb95434caaf8875cc73991802e2c8c081e1b1734
MD5 5083e6239f4cd7aefbd120ebeb261bd7
BLAKE2b-256 b2492430049bc366d1d4f9e6fa62c8f7dc92ea908772e7a0f9ef4388f3c68044

See more details on using hashes here.

File details

Details for the file django_fake_model-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_fake_model-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2f43723744eff2079563fe78d6859429aefa606aa3ad96deb3e81274a2df528
MD5 1a602e4a659564a935dd16166660e6d6
BLAKE2b-256 70dc25f0ba8c9241c04618bc7e3eb38d85f2f55da4a4a0b0c256f6f9f73fe99c

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