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')
TODO:
fix class decorator @YourModel.fake_me for nose tests
History
0.1.0 (2015-09-16)
First release on PyPI.
0.1.1 (2015-09-28)
Added tests with different databases.
0.1.2 (2015-11-13)
Added Django 1.9 support
Added travis config generator
Added nose tests
Remove tests for Django master
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
Hashes for django_fake_model-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3bf10bacd7ef64f5051996e0188a70b3d8bc0336e0debff678889028b17bf7d |
|
MD5 | 9aefe0ed2446e817910226409cd01698 |
|
BLAKE2b-256 | e39921f9f74a6a1c1285d5df1ebb51f01d69b452f69b0fdb571bee92701320cf |