=============================
django-fake-model
=============================
.. image:: https://badge.fury.io/py/django-fake-model.png
:target: https://badge.fury.io/py/django-fake-model
.. image:: https://travis-ci.org/erm0l0v/django-fake-model.png?branch=master
:target: https://travis-ci.org/erm0l0v/django-fake-model
.. image:: https://landscape.io/github/erm0l0v/django-fake-model/master/landscape.svg?style=flat
:target: https://landscape.io/github/erm0l0v/django-fake-model/master
:alt: Code Health
.. image:: https://api.codacy.com/project/badge/235f71efbf3144178975bb3eb86964c8
:target: https://www.codacy.com/app/erm0l0v/django-fake-model
.. image:: https://requires.io/github/erm0l0v/django-fake-model/requirements.svg?branch=master
:target: https://requires.io/github/erm0l0v/django-fake-model/requirements/?branch=master
:alt: Requirements Status
.. image:: https://codecov.io/github/erm0l0v/django-fake-model/coverage.svg?branch=master
:target: https://codecov.io/github/erm0l0v/django-fake-model?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.
.. code:: python
from django_fake_model import models as f
from django.db import models
from django.test import TestCase, TransactionTestCase
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')
class RelatedModel(f.FakeModel):
text = models.CharField(max_length=400)
class NyModel(f.FakeModel):
text = models.CharField(max_length=400)
related_model = models.ForeignKey(RelatedModel)
@NyModel.fake_me
@RelatedModel.fake_me
class TestRelatedModelsClassDecorator(TransactionTestCase):
def test_create_models(self):
related_model = RelatedModel()
related_model.text = 'qwerty'
related_model.save()
my_model = NyModel()
my_model.test = 'qwerty'
my_model.related_model = related_model
my_model.save()
self.assertIsNotNone(my_model)
self.assertIsNotNone(related_model)
Development:
------------
To develop on this locally with `Docker`_, install the Docker Engine and
`Docker Compose`_. Then you can build the Docker image and run the tests
on all tox activities(this also uses a shared pip cache to reduce download
times)::
docker-compose up -d pg mysql
docker-compose run --rm test
If you wanna run just one Tox activity you can specify that as well::
docker-compose run --rm test tox -e py35-dj19-mysql-unittest
If you add any dependencies or change the tox configuration, you have
to rebuild the image::
docker-compose build
It will share this folder with the Docker containers, so that
.. _Docker: https://www.docker.com/
.. _Docker Compose: https://docs.docker.com/compose/
Cookiecutter Tools Used in Making This Package
----------------------------------------------
* cookiecutter
* cookiecutter-djangopackage
History
-------
0.1.4 (2016-02-08)
++++++++++++++++++
* Fix class decorator `fake_me` for nose tests
0.1.3 (2015-12-23)
++++++++++++++++++
* Fix issue #1 Multiple Fake Models. Thanks to Saul Shanabrook (@saulshanabrook)
* Add support for developing with Docker. Thanks to Saul Shanabrook again
0.1.2 (2015-11-13)
++++++++++++++++++
* Added Django 1.9 support
* Added travis config generator
* Added nose tests
* Remove tests for Django master
0.1.1 (2015-09-28)
++++++++++++++++++
* Added tests with different databases.
0.1.0 (2015-09-16)
++++++++++++++++++
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/erm0l0v/django-fake-model",
"name": "django-fake-model",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django-fake-model",
"author": "Kirill Ermolov",
"author_email": "erm0l0v@ya.ru",
"download_url": "https://files.pythonhosted.org/packages/0f/e1/8f330ca5dfb930850b1f232a0eaba6576befa890ac3e7e4ea950b54ad411/django-fake-model-0.1.4.tar.gz",
"platform": "UNKNOWN",
"description": "=============================\ndjango-fake-model\n=============================\n\n.. image:: https://badge.fury.io/py/django-fake-model.png\n :target: https://badge.fury.io/py/django-fake-model\n\n.. image:: https://travis-ci.org/erm0l0v/django-fake-model.png?branch=master\n :target: https://travis-ci.org/erm0l0v/django-fake-model\n\n.. image:: https://landscape.io/github/erm0l0v/django-fake-model/master/landscape.svg?style=flat\n :target: https://landscape.io/github/erm0l0v/django-fake-model/master\n :alt: Code Health\n\n.. image:: https://api.codacy.com/project/badge/235f71efbf3144178975bb3eb86964c8\n :target: https://www.codacy.com/app/erm0l0v/django-fake-model\n\n.. image:: https://requires.io/github/erm0l0v/django-fake-model/requirements.svg?branch=master\n :target: https://requires.io/github/erm0l0v/django-fake-model/requirements/?branch=master\n :alt: Requirements Status\n\n.. image:: https://codecov.io/github/erm0l0v/django-fake-model/coverage.svg?branch=master\n :target: https://codecov.io/github/erm0l0v/django-fake-model?branch=master\n\nSimple library for creating fake models in the unit tests.\n\nThis 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.\n\nInstall\n-------\n\nInstall django-fake-model::\n\n pip install django-fake-model\n\nQuickstart\n----------\n\nJust create a model in any file (Ex: in your test) and add decorator **@YourModel.fake_me** to test method or test class.\n\n.. code:: python\n\n from django_fake_model import models as f\n from django.db import models\n from django.test import TestCase, TransactionTestCase\n\n\n class MyFakeModel(f.FakeModel):\n\n name = models.CharField(max_length=100)\n\n\n @MyFakeModel.fake_me\n class MyFakeModelTests(TestCase):\n\n def test_create_model(self):\n MyFakeModel.objects.create(name='123')\n model = MyFakeModel.objects.get(name='123')\n self.assertEqual(model.name, '123')\n\n\n class MyFakeModelFunctionTest(TestCase):\n\n @MyFakeModel.fake_me\n def test_create_model(self):\n MyFakeModel.objects.create(name='123')\n model = MyFakeModel.objects.get(name='123')\n self.assertEqual(model.name, '123')\n\n\n class RelatedModel(f.FakeModel):\n text = models.CharField(max_length=400)\n\n\n class NyModel(f.FakeModel):\n text = models.CharField(max_length=400)\n related_model = models.ForeignKey(RelatedModel)\n\n\n @NyModel.fake_me\n @RelatedModel.fake_me\n class TestRelatedModelsClassDecorator(TransactionTestCase):\n\n def test_create_models(self):\n related_model = RelatedModel()\n related_model.text = 'qwerty'\n related_model.save()\n my_model = NyModel()\n my_model.test = 'qwerty'\n my_model.related_model = related_model\n my_model.save()\n self.assertIsNotNone(my_model)\n self.assertIsNotNone(related_model)\n\n\nDevelopment:\n------------\n\nTo develop on this locally with `Docker`_, install the Docker Engine and\n`Docker Compose`_. Then you can build the Docker image and run the tests\non all tox activities(this also uses a shared pip cache to reduce download\ntimes)::\n\n docker-compose up -d pg mysql\n docker-compose run --rm test\n\nIf you wanna run just one Tox activity you can specify that as well::\n\n docker-compose run --rm test tox -e py35-dj19-mysql-unittest\n\nIf you add any dependencies or change the tox configuration, you have\nto rebuild the image::\n\n docker-compose build\n\nIt will share this folder with the Docker containers, so that\n\n\n.. _Docker: https://www.docker.com/\n.. _Docker Compose: https://docs.docker.com/compose/\n\n\nCookiecutter Tools Used in Making This Package\n----------------------------------------------\n\n* cookiecutter\n* cookiecutter-djangopackage\n\n\n\n\nHistory\n-------\n\n0.1.4 (2016-02-08)\n++++++++++++++++++\n\n* Fix class decorator `fake_me` for nose tests\n\n\n0.1.3 (2015-12-23)\n++++++++++++++++++\n\n* Fix issue #1 Multiple Fake Models. Thanks to Saul Shanabrook (@saulshanabrook)\n* Add support for developing with Docker. Thanks to Saul Shanabrook again\n\n0.1.2 (2015-11-13)\n++++++++++++++++++\n\n* Added Django 1.9 support\n* Added travis config generator\n* Added nose tests\n* Remove tests for Django master\n\n0.1.1 (2015-09-28)\n++++++++++++++++++\n\n* Added tests with different databases.\n\n0.1.0 (2015-09-16)\n++++++++++++++++++\n\n* First release on PyPI.",
"bugtrack_url": null,
"license": "BSD",
"summary": "Simple library for creating fake models in the unit tests.",
"version": "0.1.4",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/erm0l0v/django-fake-model"
},
"split_keywords": [
"django-fake-model"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "27bd3e9132c29a5d805e7bfac37940072c2c1e1f5cac892707696863e3895fd4",
"md5": "8e79c7aca2f56571d3261e1aba4ddd8f",
"sha256": "5f5bd31a8825cb561f6df1dc2d8efbe1ba46f2082aa584d6438862b3e040e5f6"
},
"downloads": -1,
"filename": "django_fake_model-0.1.4-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8e79c7aca2f56571d3261e1aba4ddd8f",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 7122,
"upload_time": "2016-02-08T11:41:12",
"upload_time_iso_8601": "2016-02-08T11:41:12.846204Z",
"url": "https://files.pythonhosted.org/packages/27/bd/3e9132c29a5d805e7bfac37940072c2c1e1f5cac892707696863e3895fd4/django_fake_model-0.1.4-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0fe18f330ca5dfb930850b1f232a0eaba6576befa890ac3e7e4ea950b54ad411",
"md5": "4df725c9c26b96b47706189134add16b",
"sha256": "44940dea141be48ccffeab917c69de3a70c98cb45c3a2a224c2a800b57913965"
},
"downloads": -1,
"filename": "django-fake-model-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "4df725c9c26b96b47706189134add16b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6092,
"upload_time": "2016-02-08T11:39:25",
"upload_time_iso_8601": "2016-02-08T11:39:25.149652Z",
"url": "https://files.pythonhosted.org/packages/0f/e1/8f330ca5dfb930850b1f232a0eaba6576befa890ac3e7e4ea950b54ad411/django-fake-model-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2016-02-08 11:39:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "erm0l0v",
"github_project": "django-fake-model",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "django",
"specs": [
[
">=",
"1.8.0"
]
]
},
{
"name": "wheel",
"specs": [
[
">=",
"0.24.0"
]
]
}
],
"tox": true,
"lcname": "django-fake-model"
}