Simple library for creating fake models in the unit tests.
Project description
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')
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
Built Distribution
File details
Details for the file django-fake-model-0.1.1.tar.gz
.
File metadata
- Download URL: django-fake-model-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d72e7b278445556829e8108fb95434caaf8875cc73991802e2c8c081e1b1734 |
|
MD5 | 5083e6239f4cd7aefbd120ebeb261bd7 |
|
BLAKE2b-256 | b2492430049bc366d1d4f9e6fa62c8f7dc92ea908772e7a0f9ef4388f3c68044 |
File details
Details for the file django_fake_model-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_fake_model-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2f43723744eff2079563fe78d6859429aefa606aa3ad96deb3e81274a2df528 |
|
MD5 | 1a602e4a659564a935dd16166660e6d6 |
|
BLAKE2b-256 | 70dc25f0ba8c9241c04618bc7e3eb38d85f2f55da4a4a0b0c256f6f9f73fe99c |