Skip to content
Browse files

renaming the whole thing

  • Loading branch information...
1 parent 1d75221 commit f70bcfe92bacd26059346ada3c37f507e17799e7 Mikko Hellsing committed Oct 15, 2010
Showing with 596 additions and 298 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 AUTHORS.txt
  3. +8 −1 CHANGES.rst
  4. +31 −0 LICENSE.txt
  5. +1 −0 MANIFEST.in
  6. +38 −54 README.rst
  7. +0 −4 autofixture/__init__.py
  8. +2 −2 docs/Makefile
  9. +229 −0 docs/_theme/nature/static/nature.css_t
  10. +54 −0 docs/_theme/nature/static/pygments.css
  11. +4 −0 docs/_theme/nature/theme.conf
  12. +9 −9 docs/conf.py
  13. +0 −17 docs/contents.rst
  14. +2 −2 docs/contribute.rst
  15. +10 −10 docs/index.rst
  16. +14 −14 docs/installation.rst
  17. +0 −6 docs/loadtestdata.rst
  18. +2 −2 docs/make.bat
  19. +6 −0 docs/mockups.rst
  20. +16 −16 docs/registry.rst
  21. +14 −14 docs/usage.rst
  22. +4 −0 mockups/__init__.py
  23. +8 −8 {autofixture → mockups}/base.py
  24. 0 {autofixture → mockups}/constraints.py
  25. 0 {autofixture_tests/sample_app → mockups/contrib}/__init__.py
  26. +10 −10 {autofixture → mockups}/contrib/auth.py
  27. +4 −4 {autofixture → mockups}/generators.py
  28. +25 −23 {autofixture → mockups}/helpers.py
  29. 0 {autofixture_tests/generator_test → mockups/management}/__init__.py
  30. 0 {autofixture_tests/autofixture_test → mockups/management/commands}/__init__.py
  31. +12 −13 autofixture/management/commands/loadtestdata.py → mockups/management/commands/mockups.py
  32. 0 {autofixture_tests → mockups}/models.py
  33. 0 {autofixture → mockups}/signals.py
  34. 0 {autofixture_tests → mockups_tests}/__init__.py
  35. 0 {autofixture/management/commands → mockups_tests/generator_test}/__init__.py
  36. 0 {autofixture_tests → mockups_tests}/generator_test/models.py
  37. +2 −1 {autofixture_tests → mockups_tests}/generator_test/tests.py
  38. 0 {autofixture_tests → mockups_tests}/media/emptyfiles/empty.txt
  39. 0 {autofixture_tests → mockups_tests}/media/emptyfiles/nofilextension
  40. 0 {autofixture_tests → mockups_tests}/media/textfiles/ispum.txt
  41. 0 {autofixture_tests → mockups_tests}/media/textfiles/lorem.txt
  42. BIN mockups_tests/mockups_test/.tests.py.swn
  43. 0 {autofixture/management → mockups_tests/mockups_test}/__init__.py
  44. 0 {autofixture_tests/autofixture_test → mockups_tests/mockups_test}/models.py
  45. +65 −65 {autofixture_tests/autofixture_test → mockups_tests/mockups_test}/tests.py
  46. 0 {autofixture → mockups_tests}/models.py
  47. 0 mockups_tests/sample_app/__init__.py
  48. +1 −1 {autofixture_tests → mockups_tests}/sample_app/admin.py
  49. 0 {autofixture_tests → mockups_tests}/sample_app/models.py
  50. +2 −2 {autofixture_tests → mockups_tests}/urls.py
  51. +3 −3 runtests.py
  52. +8 −8 settings.py
  53. +9 −9 setup.py
View
1 .gitignore
@@ -11,3 +11,4 @@ src/*.egg-info
docs/_build
*.pyc
*.swp
+*.swo
View
2 AUTHORS.txt
@@ -0,0 +1,2 @@
+Gregor Müllegger <gregor@muellegger.de>
+Mikko Hellsing <mikko@aino.se>
View
9 CHANGES.rst
@@ -1,6 +1,13 @@
Changelog
=========
+0.2.6
+-----
+* Changing syntax to match Django Models & Forms
+
+* Renaming to django-mockups
+
+
0.2.5
-----
@@ -23,4 +30,4 @@ Changelog
* Fixing bug when a ``CharField`` with ``max_length`` smaller than 15 is used.
-* ``AutoFixture.field_values`` accepts callables as values.
+* ``Mockup.field_generators`` accepts callables as values.
View
31 LICENSE.txt
@@ -1,3 +1,34 @@
+DJANGO MOCKUPS
+==============
+Copyright (c) 2010, Mikko Hellsing
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the author nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+DJANGO AUTOFIXTURE
+==================
Copyright (c) 2010, Gregor Müllegger
All rights reserved.
View
1 MANIFEST.in
@@ -1,3 +1,4 @@
+include AUTHORS.txt
include CHANGES.rst
include LICENSE.txt
include MANIFEST.in
View
92 README.rst
@@ -1,48 +1,47 @@
==================
-django-autofixture
+django-mockups
==================
This app aims to provide a simple way of loading masses of randomly generated
test data into your development database. You can use a management command to
load test data through command line.
-It is named *autofixture* because of the similarity of how I mainly used
-django's fixtures. Usually you add test data through the admin to see how your
-site looks with non static pages. You export data by using ``dumpdata`` to
-send it to your colleagues or to preserve it before you make a ``manage.py
-reset app`` and so on. Your site gets more and more complex and adding test
-data gets more and more annoying.
+Usually you add test data through the admin to see how your site looks with non
+static pages. You export data by using ``dumpdata`` to send it to your
+colleagues or to preserve it before you make a ``manage.py reset app`` and so
+on. Your site gets more and more complex and adding test data gets more and
+more annoying.
-This is the usecase where autofixtures should help you to save time that can
+This is the usecase where mockups should help you to save time that can
actually be spent on hacking.
Installation
============
-You must make the ``autofixture`` package available on your python path.
-Either drop it into your project directory or install it from the python
-package index with ``pip install django-autofixture``. You can also use
-``easy_install django-autofixture`` if you don't have pip available.
+You must make the ``mockups`` package available on your python path. Either
+drop it into your project directory or install it from the python package index
+with ``pip install django-mockups``. You can also use ``easy_install
+django-mockups`` if you don't have pip available.
-To use the management command you must add ``'autofixture'`` to the
+To use the management command you must add ``'mockups'`` to the
``INSTALLED_APPS`` setting in your django settings file. You don't need to do
-this if you want to use the ``autofixture`` package only as library.
+this if you want to use the ``mockups`` package only as library.
Management command
==================
-The ``loadtestdata`` accepts the following syntax::
+The ``mockups`` accepts the following syntax::
- django-admin.py loadtestdata [options] app.Model:# [app.Model:# ...]
+ django-admin.py mockups [options] app.Model:# [app.Model:# ...]
Its nearly self explanatory. Supply names of models, prefixed with its app
name. After that, place a colon and tell the command how many objects you want
to create. Here is an example how to create three categories and twenty
entries for you blogging app::
- django-admin.py loadtestdata blog.Category:3 blog.Entry:20
+ django-admin.py mockups blog.Category:3 blog.Entry:20
Voila! You have ready to use testing data populated to your database. The
model fields are filled with data by producing randomly generated values
@@ -56,60 +55,61 @@ populated with existing data or if the related models are also generated on
the fly. Please have a look at the help page of the command for more
information::
- django-admin.py help loadtestdata
+ django-admin.py help mockups
-Using autofixtures as tool for unittests
+Using mockups as tool for unittests
========================================
-It has proofed that autofixtures have a great use for unittests. It has always
+It has proofed that mockups have a great use for unittests. It has always
bugged me that creating complex models for testing their behaviour was
complicated. Sometimes models have strict restrictions or many related objects
which they depend on. One solution would be to use traditional fixtures
dumped from your production database. But while in development when database
schemes are changing frequently, its hard to maintain all fixtures and to know
exactly which objects are contained in the dumps etc...
-Autofixtures to the rescue! It lets you automatically generate models and all
+Mockups to the rescue! It lets you automatically generate models and all
of their dependecies on the fly. Have a look at the following examples.
-Lets start with the very basics. We create an ``AutoFixture`` instance for the
+Lets start with the very basics. We create a ``Mockup`` instance for the
``Entry`` model and tell it to create ten model instances::
- from autofixture import AutoFixture
- fixture = AutoFixture(Entry)
- entries = fixture.create(10)
+ from mockups import Mockup
+ mockup = Mockup(Entry)
+ entries = mockup.create(10)
Now you can play around and test your blog entries. By default dependecies of
foreignkeys and many to many relations are solved by randomly selecting an
already existing object of the related model. What if you don't have one yet?
-You can provide the ``generate_fk`` attribute which allows the autofixture
+You can provide the ``generate_fk`` attribute which allows the mockup
instance to follow foreignkeys by generating new related models::
- fixture = AutoFixture(Entry, generate_fk=True)
+ mockup = Mockup(Entry, generate_fk=True)
This generates new instance for *all* foreignkey fields of ``Entry``. Its
possible to limit this behaviour to single fields::
- fixture = AutoFixture(Entry, generate_fk=['author'])
+ mockup = Mockup(Entry, generate_fk=['author'])
This will only create new authors automatically and doesn't touch other
tables. The same is possible with many to many fields. But you need
additionally specify how many objects should be created for the m2m relation::
- fixture = AutoFixture(Entry, generate_m2m={'categories': (1,3)})
+ mockup = Mockup(Entry, generate_m2m={'categories': (1,3)})
All created entry models get one to three new categories assigned.
Setting custom values for fields
--------------------------------
However its often necessary to be sure that a specific field must have a
-specific value. This is easily achieved with the ``field_values`` attribute of
-``AutoFixture``::
+specific value. This is easily achieved with the ``field_generators`` attribute of
+``Mockup``::
- fixture = AutoFixture(Entry,
- field_values={'pub_date': datetime(2010, 2, 1)})
+ mockup = Mockup(Entry, field_generators={
+ 'pub_date': datetime(2010, 2, 1)
+ })
More
@@ -118,8 +118,8 @@ More
There is so much more to explore which might be useful for you and your
projects:
-* There are ways to register custom ``AutoFixture`` subclasses with models
- that are automatically used when calling ``loadtestdata`` on the model.
+* There are ways to register custom ``Mockup`` subclasses with models
+ that are automatically used when calling ``mockups`` on the model.
* More control for related models, even with relations of related models...
(e.g. by using ``generate_fk=['author', 'author__user']``)
* Custom constraints that are used to ensure that created the models are
@@ -128,23 +128,7 @@ projects:
I hope to explain this in the future with more details in a documentation. It
will be written but is not finished yet. I wanted to get this project out to
-support you in development. But since its only python code you can easily
-study the source on your own and see in which ways it can be used. There are
-already some parts documented with doc strings which might also be helpful for you.
+support you in development. But since its only python code you can easily study
+the source on your own and see in which ways it can be used. There are already
+some parts documented with doc strings which might also be helpful for you.
-
-Future development
-==================
-
-The ``autofixture`` app is nearly feature complete from the point I wanted to
-have while starting development. But there is still much room for
-improvements. One feature you can expect in the future is for example support
-for multiple databases which was introduced by django 1.2. If you have any
-ideas or interests to contribute: Feel free to contact me or just start
-hacking.
-
-Email me (gregor@muellegger.de), contact me on twitter
-(@gregmuellegger) or fork the git repository on github (``git clone
-git://github.com/gregmuellegger/django-autofixture.git``).
-
-Happy autofixturing!
View
4 autofixture/__init__.py
@@ -1,4 +0,0 @@
-from autofixture.helpers import *
-from autofixture.base import AutoFixture
-from autofixture.constraints import InvalidConstraint
-
View
4 docs/Makefile
@@ -61,9 +61,9 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-autofixture.qhcp"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-mockups.qhcp"
@echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-autofixture.qhc"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-mockups.qhc"
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
View
229 docs/_theme/nature/static/nature.css_t
@@ -0,0 +1,229 @@
+/**
+ * Sphinx stylesheet -- default theme
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+@import url("basic.css");
+
+/* -- page layout ----------------------------------------------------------- */
+
+body {
+ font-family: Arial, sans-serif;
+ font-size: 100%;
+ background-color: #111;
+ color: #555;
+ margin: 0;
+ padding: 0;
+}
+
+div.documentwrapper {
+ float: left;
+ width: 100%;
+}
+
+div.bodywrapper {
+ margin: 0 0 0 230px;
+}
+
+hr{
+ border: 1px solid #B1B4B6;
+}
+
+div.document {
+ background-color: #eee;
+}
+
+div.body {
+ background-color: #ffffff;
+ color: #3E4349;
+ padding: 0 30px 30px 30px;
+ font-size: 0.8em;
+}
+
+div.footer {
+ color: #555;
+ width: 100%;
+ padding: 13px 0;
+ text-align: center;
+ font-size: 75%;
+}
+
+div.footer a {
+ color: #444;
+ text-decoration: underline;
+}
+
+div.related {
+ background-color: #6BA81E;
+ line-height: 32px;
+ color: #fff;
+ text-shadow: 0px 1px 0 #444;
+ font-size: 0.80em;
+}
+
+div.related a {
+ color: #E2F3CC;
+}
+
+div.sphinxsidebar {
+ font-size: 0.75em;
+ line-height: 1.5em;
+}
+
+div.sphinxsidebarwrapper{
+ padding: 20px 0;
+}
+
+div.sphinxsidebar h3,
+div.sphinxsidebar h4 {
+ font-family: Arial, sans-serif;
+ color: #222;
+ font-size: 1.2em;
+ font-weight: normal;
+ margin: 0;
+ padding: 5px 10px;
+ background-color: #ddd;
+ text-shadow: 1px 1px 0 white
+}
+
+div.sphinxsidebar h4{
+ font-size: 1.1em;
+}
+
+div.sphinxsidebar h3 a {
+ color: #444;
+}
+
+
+div.sphinxsidebar p {
+ color: #888;
+ padding: 5px 20px;
+}
+
+div.sphinxsidebar p.topless {
+}
+
+div.sphinxsidebar ul {
+ margin: 10px 20px;
+ padding: 0;
+ color: #000;
+}
+
+div.sphinxsidebar a {
+ color: #444;
+}
+
+div.sphinxsidebar input {
+ border: 1px solid #ccc;
+ font-family: sans-serif;
+ font-size: 1em;
+}
+
+div.sphinxsidebar input[type=text]{
+ margin-left: 20px;
+}
+
+/* -- body styles ----------------------------------------------------------- */
+
+a {
+ color: #005B81;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #E32E00;
+ text-decoration: underline;
+}
+
+div.body h1,
+div.body h2,
+div.body h3,
+div.body h4,
+div.body h5,
+div.body h6 {
+ font-family: Arial, sans-serif;
+ background-color: #BED4EB;
+ font-weight: normal;
+ color: #212224;
+ margin: 30px 0px 10px 0px;
+ padding: 5px 0 5px 10px;
+ text-shadow: 0px 1px 0 white
+}
+
+div.body h1 { border-top: 20px solid white; margin-top: 0; font-size: 200%; }
+div.body h2 { font-size: 150%; background-color: #C8D5E3; }
+div.body h3 { font-size: 120%; background-color: #D8DEE3; }
+div.body h4 { font-size: 110%; background-color: #D8DEE3; }
+div.body h5 { font-size: 100%; background-color: #D8DEE3; }
+div.body h6 { font-size: 100%; background-color: #D8DEE3; }
+
+a.headerlink {
+ color: #c60f0f;
+ font-size: 0.8em;
+ padding: 0 4px 0 4px;
+ text-decoration: none;
+}
+
+a.headerlink:hover {
+ background-color: #c60f0f;
+ color: white;
+}
+
+div.body p, div.body dd, div.body li {
+ line-height: 1.5em;
+}
+
+div.admonition p.admonition-title + p {
+ display: inline;
+}
+
+div.highlight{
+ background-color: white;
+}
+
+div.note {
+ background-color: #eee;
+ border: 1px solid #ccc;
+}
+
+div.seealso {
+ background-color: #ffc;
+ border: 1px solid #ff6;
+}
+
+div.topic {
+ background-color: #eee;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+p.admonition-title {
+ display: inline;
+}
+
+p.admonition-title:after {
+ content: ":";
+}
+
+pre {
+ padding: 10px;
+ background-color: White;
+ color: #222;
+ line-height: 1.2em;
+ border: 1px solid #C6C9CB;
+ font-size: 1.2em;
+ margin: 1.5em 0 1.5em 0;
+ -webkit-box-shadow: 1px 1px 1px #d8d8d8;
+ -moz-box-shadow: 1px 1px 1px #d8d8d8;
+}
+
+tt {
+ background-color: #ecf0f3;
+ color: #222;
+ padding: 1px 2px;
+ font-size: 1.2em;
+ font-family: monospace;
+}
View
54 docs/_theme/nature/static/pygments.css
@@ -0,0 +1,54 @@
+.c { color: #999988; font-style: italic } /* Comment */
+.k { font-weight: bold } /* Keyword */
+.o { font-weight: bold } /* Operator */
+.cm { color: #999988; font-style: italic } /* Comment.Multiline */
+.cp { color: #999999; font-weight: bold } /* Comment.preproc */
+.c1 { color: #999988; font-style: italic } /* Comment.Single */
+.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #aa0000 } /* Generic.Error */
+.gh { color: #999999 } /* Generic.Heading */
+.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
+.go { color: #111 } /* Generic.Output */
+.gp { color: #555555 } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #aaaaaa } /* Generic.Subheading */
+.gt { color: #aa0000 } /* Generic.Traceback */
+.kc { font-weight: bold } /* Keyword.Constant */
+.kd { font-weight: bold } /* Keyword.Declaration */
+.kp { font-weight: bold } /* Keyword.Pseudo */
+.kr { font-weight: bold } /* Keyword.Reserved */
+.kt { color: #445588; font-weight: bold } /* Keyword.Type */
+.m { color: #009999 } /* Literal.Number */
+.s { color: #bb8844 } /* Literal.String */
+.na { color: #008080 } /* Name.Attribute */
+.nb { color: #999999 } /* Name.Builtin */
+.nc { color: #445588; font-weight: bold } /* Name.Class */
+.no { color: #ff99ff } /* Name.Constant */
+.ni { color: #800080 } /* Name.Entity */
+.ne { color: #990000; font-weight: bold } /* Name.Exception */
+.nf { color: #990000; font-weight: bold } /* Name.Function */
+.nn { color: #555555 } /* Name.Namespace */
+.nt { color: #000080 } /* Name.Tag */
+.nv { color: purple } /* Name.Variable */
+.ow { font-weight: bold } /* Operator.Word */
+.mf { color: #009999 } /* Literal.Number.Float */
+.mh { color: #009999 } /* Literal.Number.Hex */
+.mi { color: #009999 } /* Literal.Number.Integer */
+.mo { color: #009999 } /* Literal.Number.Oct */
+.sb { color: #bb8844 } /* Literal.String.Backtick */
+.sc { color: #bb8844 } /* Literal.String.Char */
+.sd { color: #bb8844 } /* Literal.String.Doc */
+.s2 { color: #bb8844 } /* Literal.String.Double */
+.se { color: #bb8844 } /* Literal.String.Escape */
+.sh { color: #bb8844 } /* Literal.String.Heredoc */
+.si { color: #bb8844 } /* Literal.String.Interpol */
+.sx { color: #bb8844 } /* Literal.String.Other */
+.sr { color: #808000 } /* Literal.String.Regex */
+.s1 { color: #bb8844 } /* Literal.String.Single */
+.ss { color: #bb8844 } /* Literal.String.Symbol */
+.bp { color: #999999 } /* Name.Builtin.Pseudo */
+.vc { color: #ff99ff } /* Name.Variable.Class */
+.vg { color: #ff99ff } /* Name.Variable.Global */
+.vi { color: #ff99ff } /* Name.Variable.Instance */
+.il { color: #009999 } /* Literal.Number.Integer.Long */
View
4 docs/_theme/nature/theme.conf
@@ -0,0 +1,4 @@
+[theme]
+inherit = basic
+stylesheet = nature.css
+pygments_style = tango
View
18 docs/conf.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# django-autofixture documentation build configuration file, created by
+# django-mockups documentation build configuration file, created by
# sphinx-quickstart on Mon Mar 8 22:17:43 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
@@ -45,17 +45,17 @@
master_doc = 'index'
# General information about the project.
-project = u'django-autofixture'
-copyright = u'2010, Gregor Müllegger'
+project = u'django-mockups'
+copyright = u'2010, Mikko Hellsing'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '0.3.0'
+version = '0.2.6'
# The full version, including alpha/beta/rc tags.
-release = '0.3.0'
+release = '0.2.6'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -99,7 +99,7 @@
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
+html_theme = 'nature'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -166,7 +166,7 @@
#html_file_suffix = ''
# Output file base name for HTML help builder.
-htmlhelp_basename = 'django-autofixturedoc'
+htmlhelp_basename = 'django-mockupsdoc'
# -- Options for LaTeX output --------------------------------------------------
@@ -180,8 +180,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'django-autofixture.tex', u'django-autofixture Documentation',
- u'Gregor Müllegger', 'manual'),
+ ('index', 'django-mockups.tex', u'django-mockups Documentation',
+ u'Mikko Hellsing', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
View
17 docs/contents.rst
@@ -1,17 +0,0 @@
-.. _contents:
-
-``django-autofixture`` documentation contents
-=============================================
-
-.. toctree::
- :maxdepth: 2
-
- installation
- loadtestdata
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
View
4 docs/contribute.rst
@@ -2,14 +2,14 @@ Contribute
==========
If you want to use an isolated environment while hacking on
-``django-autofixture`` you can run the following commands from the project's
+``django-mockups`` you can run the following commands from the project's
root directory::
virtualenv . --no-site-packages
source bin/activate
pip install -r requirements.txt
-Please run now the tests that are shipped with ``autofixture`` to see if
+Please run now the tests that are shipped with ``mockups`` to see if
everything is working::
python runtests.py
View
20 docs/index.rst
@@ -1,18 +1,17 @@
-Welcome to django-autofixture's documentation!
+Welcome to django-mockups's documentation!
==============================================
This app aims to provide a simple way of loading masses of randomly generated
test data into your development database. You can use a :ref:`management
-command <loadtestdata>` to load test data through command line.
+command <mockups>` to load test data through command line.
-It is named *autofixture* because of the similarity of how I mainly used
-django's fixtures. Usually you add test data through the admin to see how your
-site looks with non static pages. You export data by using ``dumpdata`` to
-send it to your colleagues or to preserve it before you make a ``manage.py
-reset app`` and so on. Your site gets more and more complex and adding test
-data gets more and more annoying.
+Usually you add test data through the admin to see how your site looks with non
+static pages. You export data by using ``dumpdata`` to send it to your
+colleagues or to preserve it before you make a ``manage.py reset app`` and so
+on. Your site gets more and more complex and adding test data gets more and
+more annoying.
-This is the usecase where autofixtures should help you to save time that can
+This is the usecase where mockups should help you to save time that can
actually be spent on hacking.
.. _contents:
@@ -24,6 +23,7 @@ Contents
:maxdepth: 2
installation
- loadtestdata
+ mockups
usage
registry
+ contribute
View
28 docs/installation.rst
@@ -1,34 +1,34 @@
Installation
============
-Download and install with ``pip`` or ``easy_install``
------------------------------------------------------
+Download and install with pip or easy_install
+---------------------------------------------
-You can install the ``django-autofixture`` like any other python package. The
+You can install the ``django-mockups`` like any other python package. The
prefered way is to use `pip <http://pypi.python.org/pypi/pip>`_. Please run the
following command in your terminal::
- pip install django-autofixture
+ pip install django-mockups
This will install the package in your system wide python installation.
You can fall back to the :command:`easy_install` command if :command:`pip` is
not available on your system::
- easy_install django-autofixture
+ easy_install django-mockups
.. note:: In most cases you need admin previlegies to install a package into
your system. You can get these previlegies by prefixing the commands above
with ``sudo``.
.. _INSTALLED_APPS:
-Add ``autofixture`` to your django project
-------------------------------------------
+Add mockups to your django project
+----------------------------------
-Usually you want to add ``autofixture`` to your ``INSTALLED_APPS`` in the
-settings file of your django project. This will make the :ref:`loadtestdata
-<loadtestdata>` management command available to your use.
+Usually you want to add ``mockups`` to your ``INSTALLED_APPS`` in the
+settings file of your django project. This will make the :ref:`mockups
+<mockups>` management command available to your use.
Using the development version
-----------------------------
@@ -38,14 +38,14 @@ need is to have the `git <http://git-scm.com/>`_ and `setuptools
<http://pypi.python.org/pypi/setuptools>`_ installed.
Now get the repository from `github
-<http://github.net/gregmuellegger/django-autofixture>`_ and run::
+<http://github.net/sorl/django-mockups>`_ and run::
- git clone git://github.com/gregmuellegger/django-autofixture.git
+ git clone git://github.com/sorl/django-mockups.git
This will download the project into your local directory. :command:`cd` to the
-``django-autofixture`` directory and run::
+``django-mockups`` directory and run::
python setup.py install
Now follow the instructions under :ref:`INSTALLED_APPS` and everything will be
-in place to use ``django-autofixture``.
+in place to use ``django-mockups``.
View
6 docs/loadtestdata.rst
@@ -1,6 +0,0 @@
-.. _loadtestdata:
-
-The ``loadtestdata`` management command
-=======================================
-
-.. automodule:: autofixture.management.commands.loadtestdata
View
4 docs/make.bat
@@ -74,9 +74,9 @@ if "%1" == "qthelp" (
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
- echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-autofixture.qhcp
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-mockups.qhcp
echo.To view the help file:
- echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-autofixture.ghc
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-mockups.ghc
goto end
)
View
6 docs/mockups.rst
@@ -0,0 +1,6 @@
+.. _mockups:
+
+The mockups management command
+===============================
+
+.. automodule:: mockups.management.commands.mockups
View
32 docs/registry.rst
@@ -1,29 +1,29 @@
-The :class:`AutoFixture` registry
-=================================
+The mockup registry
+===================
.. _registry:
-Since :class:`AutoFixture` is designed to fit for almost all models, its very
+Since :class:`Mockup` is designed to fit for almost all models, its very
generic and doesn't know anything about the actual logic and meanings of
relations or the purpose of your model fields. This makes it sometimes a bit
-difficult to provide the correct :ref:`field_values <field values>` in all
-places where you want ``autofixture`` to instanciate your models.
+difficult to provide the correct :ref:`field_generators <field values>` in all
+places where you want ``mockups`` to instanciate your models.
-So there is a registry to register custom :class:`AutoFixture` subclasses with
+So there is a registry to register custom :class:`Mockup` subclasses with
specific models. These subclasses are then used by default if you generated
-test data either with the :ref:`loadtestdata <loadtestdata>` management
-command or with one of the :ref:`shortcuts <shortcuts>` in :mod:`autofixture`.
+test data either with the :ref:`mockups <mockups>` management
+command or with one of the :ref:`shortcuts <shortcuts>` in :mod:`mockups`.
-.. autofunction:: autofixture.register
+.. autofunction:: mockups.register
-.. autofunction:: autofixture.unregister
+.. autofunction:: mockups.unregister
-Default :class:`AutoFixture` subclasses
----------------------------------------
+Included Mockup subclasses
+--------------------------
-There are some :class:`AutoFixture` subclasses that are shipped by default
-with ``django-autofixture``. These are listed below.
+There are some :class:`Mockup` subclasses that are shipped by default
+with ``django-mockups``. These are listed below.
-.. _UserFixture:
-.. autoclass:: autofixture.autofixtures.UserFixture
+.. _UserMockup:
+.. autoclass:: mockups.contrib.auth.UserMockup
:members: __init__
View
28 docs/usage.rst
@@ -3,40 +3,40 @@
Howto use the library
=====================
-Its easy to get started with the :doc:`loadtestdata management command
-<loadtestdata>` but its quite limited if you want to have more control of how
+Its easy to get started with the :doc:`mockups management command
+<mockups>` but its quite limited if you want to have more control of how
your test data should be created. This chapter describes how you use the
library in your python environment like the shell, a custom script or in
unittests.
Creating model instances
------------------------
-The :mod:`autofixture` module contains a few shortcuts to make the creation of
+The :mod:`mockups` module contains a few shortcuts to make the creation of
test data as fast as possible.
.. _shortcuts:
-.. autofunction:: autofixture.create
+.. autofunction:: mockups.create
-.. autofunction:: autofixture.create_one
+.. autofunction:: mockups.create_one
-.. _AutoFixture:
+.. _Mockup:
-Using the :class:`AutoFixture` class
-------------------------------------
+Using the Mockup class
+----------------------
-.. autoclass:: autofixture.base.AutoFixture
- :members: __init__, add_field_value, add_constraint, check_constrains,
+.. autoclass:: mockups.base.Mockup
+ :members: __init__, add_field_generator, add_constraint, check_constrains,
create, create_one
-Subclassing :class:`AutoFixture`
+Subclassing :class:`Mockup`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The following methods may be overwritten by subclasses:
-.. automethod:: autofixture.base.AutoFixture.prepare_class
+.. automethod:: mockups.base.Mockup.prepare_class
-.. automethod:: autofixture.base.AutoFixture.post_process_instance
+.. automethod:: mockups.base.Mockup.post_process_instance
-.. automethod:: autofixture.base.AutoFixture.get_generator
+.. automethod:: mockups.base.Mockup.get_generator
View
4 mockups/__init__.py
@@ -0,0 +1,4 @@
+from mockups.helpers import *
+from mockups.base import Mockup
+from mockups.constraints import InvalidConstraint
+
View
16 autofixture/base.py → mockups/base.py
@@ -3,8 +3,8 @@
from django.db.models import fields
from django.db.models.fields import related
from django.utils.datastructures import SortedDict
-from autofixture import constraints, generators, signals
-from autofixture.helpers import get_autofixture
+from mockups import constraints, generators, signals
+from mockups.helpers import get_mockup
class CreateInstanceError(Exception):
@@ -77,7 +77,7 @@ def __new__(cls, name, bases, attrs):
return uber.__new__(cls, name, bases, attrs)
-class AutoFixture(object):
+class Mockup(object):
'''
.. We don't support the following fields yet:
@@ -214,7 +214,7 @@ def add_field_generator(self, name, value):
def add_constraint(self, constraint):
'''
- Add a *constraint* to the autofixture.
+ Add a *constraint* to the mockup.
'''
self.constraints.append(constraint)
@@ -240,7 +240,7 @@ def get_generator(self, field):
# if generate_fk is set, follow_fk is ignored.
if field.name in self.generate_fk:
return generators.InstanceGenerator(
- get_autofixture(
+ get_mockup(
field.rel.to,
follow_fk=self.follow_fk.get_deep_links(field.name),
generate_fk=self.generate_fk.get_deep_links(field.name)),
@@ -264,7 +264,7 @@ def get_generator(self, field):
if field.name in self.generate_m2m:
min_count, max_count = self.generate_m2m[field.name]
return generators.MultipleInstanceGenerator(
- get_autofixture(
+ get_mockup(
field.rel.to
),
limit_choices_to=field.rel.limit_choices_to,
@@ -384,12 +384,12 @@ def process_m2m(self, instance, field):
self_fk = self_fks[0]
min_count, max_count = self.generate_m2m[field.name]
intermediary_model = generators.MultipleInstanceGenerator(
- get_autofixture(
+ get_mockup(
through,
field_generators={
self_fk.name: generators.StaticGenerator(instance),
related_fk.name: generators.InstanceGenerator(
- get_autofixture(field.rel.to))
+ get_mockup(field.rel.to))
}),
min_count=min_count,
max_count=max_count,
View
0 autofixture/constraints.py → mockups/constraints.py
File renamed without changes.
View
0 autofixture_tests/sample_app/__init__.py → mockups/contrib/__init__.py
File renamed without changes.
View
20 autofixture/contrib/auth.py → mockups/contrib/auth.py
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
-import autofixture
+import mockups
import string
from datetime import datetime
from django.contrib.auth.models import User, UNUSABLE_PASSWORD
-from autofixture import AutoFixture
-from autofixture import generators
+from mockups import Mockup
+from mockups import generators
-class UserFixture(AutoFixture):
+class UserMockup(Mockup):
'''
- :class:`UserFixture` is automatically used by default to create new
+ :class:`UserMockup` is automatically used by default to create new
``User`` instances. It uses the following values to assure that you can
use the generated instances without any modification:
@@ -40,24 +40,24 @@ def __init__(self, *args, **kwargs):
'''
By default the password is set to an unusable value, this makes it
impossible to login with the generated users. If you want to use for
- example ``autofixture.create_one('auth.User')`` in your unittests to have
+ example ``mockups.create_one('auth.User')`` in your unittests to have
a user instance which you can use to login with the testing client you
can provide a ``username`` and a ``password`` argument. Then you can do
something like::
- autofixture.create_one('auth.User', username='foo', password='bar`)
+ mockups.create_one('auth.User', username='foo', password='bar`)
self.client.login(username='foo', password='bar')
'''
self.username = kwargs.pop('username', None)
self.password = kwargs.pop('password', None)
- super(UserFixture, self).__init__(*args, **kwargs)
+ super(UserMockup, self).__init__(*args, **kwargs)
if self.username:
self.field_generators['username'] = generators.StaticGenerator(
self.username)
def unique_email(self, model, instance):
if User.objects.filter(email=instance.email):
- raise autofixture.InvalidConstraint(('email',))
+ raise mockups.InvalidConstraint(('email',))
def prepare_class(self):
self.add_constraint(self.unique_email)
@@ -71,4 +71,4 @@ def post_process_instance(self, instance):
return instance
-autofixture.register(User, UserFixture, fail_silently=True)
+mockups.register(User, UserMockup, fail_silently=True)
View
8 autofixture/generators.py → mockups/generators.py
@@ -426,19 +426,19 @@ class InstanceGenerator(Generator):
fieldname__exact: value
fieldname__iexact: value
'''
- def __init__(self, autofixture, limit_choices_to=None, *args, **kwargs):
- self.autofixture = autofixture
+ def __init__(self, mockup, limit_choices_to=None, *args, **kwargs):
+ self.mockup = mockup
limit_choices_to = limit_choices_to or {}
for lookup, value in limit_choices_to.items():
bits = lookup.split('__')
if len(bits) == 1 or \
len(bits) == 2 and bits[1] in ('exact', 'iexact'):
- self.autofixture.add_field_generator(bits[0],
+ self.mockup.add_field_generator(bits[0],
StaticGenerator(value))
super(InstanceGenerator, self).__init__(*args, **kwargs)
def generate(self):
- return self.autofixture.create()[0]
+ return self.mockup.create()[0]
class MultipleInstanceGenerator(InstanceGenerator):
View
48 autofixture/helpers.py → mockups/helpers.py
@@ -12,20 +12,20 @@
_registry = {}
-def get_autofixture(model, *args, **kwargs):
+def get_mockup(model, *args, **kwargs):
'''
- Gets an autofixture instance for a model
+ Gets an mockup instance for a model
'''
if model not in _registry:
- from autofixture.base import AutoFixture
+ from mockups.base import Mockup
warnings.warn('Model `%s` not in registry' % model.__name__)
- cls = AutoFixture
+ cls = Mockup
else:
cls = _registry[model]
return cls(model, *args, **kwargs)
-def register(model, autofixture_cls, overwrite=False, fail_silently=False):
+def register(model, mockup_cls, overwrite=False, fail_silently=False):
'''
Register a model with the registry.
@@ -34,7 +34,7 @@ def register(model, autofixture_cls, overwrite=False, fail_silently=False):
*model* can be either a model class or a string that contains the model's
app label and class name seperated by a dot, e.g. ``"app.ModelClass"``.
- *autofixture_cls* is the :mod:`AutoFixture` subclass that shall be used to
+ *mockup_cls* is the :mod:`Mockup` subclass that shall be used to
generated instances of *model*.
By default :func:`register` will raise :exc:`ValueError` if the given
@@ -53,16 +53,16 @@ def register(model, autofixture_cls, overwrite=False, fail_silently=False):
return
raise ValueError(
u'%s.%s is already registered. You can overwrite the registered '
- u'autofixture class by providing the `overwrite` argument.' % (
+ u'mockup class by providing the `overwrite` argument.' % (
model._meta.app_label,
model._meta.object_name,
))
- _registry[model] = autofixture_cls
+ _registry[model] = mockup_cls
def unregister(model_or_iterable, fail_silently=False):
'''
- Remove one or more models from the autofixture registry.
+ Remove one or more models from the mockups registry.
'''
from django.db import models
if not isinstance(model_or_iterable, (list, tuple, set)):
@@ -85,26 +85,28 @@ def unregister(model_or_iterable, fail_silently=False):
def create(model, count, *args, **kwargs):
'''
Create *count* instances of *model* using the either an appropiate
- autofixture that was :ref:`registry <registered>` or fall back to the
- default:class:`AutoFixture` class. *model* can be a model class or its
+ mockup that was :ref:`registry <registered>` or fall back to the
+ default:class:`Mockup` class. *model* can be a model class or its
string representation (e.g. ``"app.ModelClass"``).
- All positional and keyword arguments are passed to the autofixture
+ All positional and keyword arguments are passed to the mockup
constructor. It is demonstrated in the example below which will create ten
superusers::
- import autofixture
- admins = autofixture.create('auth.User', 10, field_values={'is_superuser': True})
+ import mockups
+ admins = mockups.create('auth.User', 10, field_generators={
+ 'is_superuser': generators.StaticGenerator(True)
+ })
- .. note:: See :ref:`AutoFixture` for more information.
+ .. note:: See :ref:`Mockup` for more information.
:func:`create` will return a list of the created objects.
'''
from django.db import models
if isinstance(model, basestring):
model = models.get_model(*model.split('.', 1))
- autofixture = get_autofixture(model, *args, **kwargs)
- return autofixture.create(count)
+ mockup = get_mockup(model, *args, **kwargs)
+ return mockup.create(count)
def create_one(model, *args, **kwargs):
@@ -119,26 +121,26 @@ def create_one(model, *args, **kwargs):
def autodiscover():
"""
- Auto-discover INSTALLED_APPS autofixtures.py modules and fail silently when
- not present. This forces an import on them to register any autofixtures
+ Auto-discover INSTALLED_APPS mockup.py modules and fail silently when
+ not present. This forces an import on them to register any mockup
bits they may want.
"""
global _registry
for app in settings.INSTALLED_APPS:
mod = import_module(app)
- # Attempt to import the app's autofixtures module.
+ # Attempt to import the app's mockup module.
try:
before_import_registry = copy.copy(_registry)
- import_module('%s.autofixtures' % app)
+ import_module('%s.mockup' % app)

I would name this mockups with trailing s. This would better match naming conventions in django like models, views, utils, settings.

@sorl
Owner
sorl added a note Oct 16, 2010

good point! I'll change that

@sorl
Owner
sorl added a note Oct 18, 2010

just a major pain to call it mockups, since this is the name of the app... it caused alot of problems, so ill just keep it as "mockup".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
except Exception:
# Reset the model registry to the state before the last import
_registry = before_import_registry
# Decide whether to bubble up this error. If the app just
- # doesn't have an autofixtures module, we can ignore the error
+ # doesn't have an mockup module, we can ignore the error
# attempting to import it, otherwise we want it to bubble up.
- if module_has_submodule(mod, 'autofixtures'):
+ if module_has_submodule(mod, 'mockup'):
raise
View
0 autofixture_tests/generator_test/__init__.py → mockups/management/__init__.py
File renamed without changes.
View
0 ...ixture_tests/autofixture_test/__init__.py → mockups/management/commands/__init__.py
File renamed without changes.
View
25 ...xture/management/commands/loadtestdata.py → mockups/management/commands/mockups.py
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
'''
-Use the ``loadtestdata`` command like this::
+Use the ``mockups`` command like this::
- django-admin.py loadtestdata [options] app.Model:# [app.Model:# ...]
+ django-admin.py mockups [options] app.Model:# [app.Model:# ...]
Its nearly self explanatory. Supply names of models, prefixed with their app
name. After that, place a colon and tell the command how many objects you want
to create. Here is an example of how to create three categories and twenty
entries for you blogging app::
- django-admin.py loadtestdata blog.Category:3 blog.Entry:20
+ django-admin.py mockups blog.Category:3 blog.Entry:20
Voila! You have ready to use testing data populated to your database. The
model fields are filled with data by producing randomly generated values
@@ -23,14 +23,13 @@
the fly. Please have a look at the help page of the command for more
information::
- django-admin.py help loadtestdata
+ django-admin.py help mockups
'''
-import autofixture
+from django.core.management.base import BaseCommand, CommandError
from django.db import models
from django.db.transaction import commit_on_success
-from django.core.management.base import BaseCommand, CommandError
from django.utils.importlib import import_module
-from autofixture import signals
+from ..mockups import create, signals, autodiscover
from optparse import make_option
@@ -73,8 +72,8 @@ class Command(BaseCommand):
u'field1:min:max,field2:min:max ...'),
make_option('-u', '--use', action='store', dest='use',
default='', help=
- u'Specify a autofixture subclass that is used to create the '
- u'test data. E.g. myapp.autofixtures.MyAutoFixture'),
+ u'Specify a mockup subclass that is used to create the '
+ u'test data. E.g. myapp.mockup.MyMockup'),
)
def format_output(self, obj):
@@ -201,7 +200,7 @@ def handle(self, *attrs, **options):
signals.instance_created.connect(
self.print_instance)
- autofixture.autodiscover()
+ autodiscover()
kwargs = {
'follow_fk': follow_fk,
@@ -212,8 +211,8 @@ def handle(self, *attrs, **options):
for model, count in models:
if use:
- fixture = use(model, **kwargs)
- fixture.create(count)
+ mockup = use(model, **kwargs)
+ mockup.create(count)
else:
- autofixture.create(model, count, **kwargs)
+ create(model, count, **kwargs)
View
0 autofixture_tests/models.py → mockups/models.py
File renamed without changes.
View
0 autofixture/signals.py → mockups/signals.py
File renamed without changes.
View
0 autofixture_tests/__init__.py → mockups_tests/__init__.py
File renamed without changes.
View
0 autofixture/management/commands/__init__.py → mockups_tests/generator_test/__init__.py
File renamed without changes.
View
0 autofixture_tests/generator_test/models.py → mockups_tests/generator_test/models.py
File renamed without changes.
View
3 autofixture_tests/generator_test/tests.py → mockups_tests/generator_test/tests.py
@@ -1,7 +1,7 @@
import os
from django.conf import settings
from django.test import TestCase
-from autofixture import generators
+from mockups import generators
class FilePathTests(TestCase):
@@ -21,3 +21,4 @@ def test_media_path_generator_in_subdirectory(self):
path = generate()
self.assertTrue(path.startswith('textfiles/'))
self.assertTrue(path.endswith('.txt'))
+
View
0 autofixture_tests/media/emptyfiles/empty.txt → mockups_tests/media/emptyfiles/empty.txt
File renamed without changes.
View
0 ...ure_tests/media/emptyfiles/nofilextension → ...ups_tests/media/emptyfiles/nofilextension
File renamed without changes.
View
0 autofixture_tests/media/textfiles/ispum.txt → mockups_tests/media/textfiles/ispum.txt
File renamed without changes.
View
0 autofixture_tests/media/textfiles/lorem.txt → mockups_tests/media/textfiles/lorem.txt
File renamed without changes.
View
BIN mockups_tests/mockups_test/.tests.py.swn
Binary file not shown.
View
0 autofixture/management/__init__.py → mockups_tests/mockups_test/__init__.py
File renamed without changes.
View
0 autofixture_tests/autofixture_test/models.py → mockups_tests/mockups_test/models.py
File renamed without changes.
View
130 autofixture_tests/autofixture_test/tests.py → mockups_tests/mockups_test/tests.py
@@ -1,18 +1,18 @@
# -*- coding: utf-8 -*-
-import autofixture
+import mockups
from decimal import Decimal
from datetime import date, datetime
from django.test import TestCase
-from autofixture import generators
-from autofixture.base import AutoFixture, CreateInstanceError, Link
-from autofixture_tests.autofixture_test.models import y2k
-from autofixture_tests.autofixture_test.models import (
+from mockups import generators
+from mockups.base import Mockup, CreateInstanceError, Link
+from mockups_tests.mockups_test.models import y2k
+from mockups_tests.mockups_test.models import (
SimpleModel, OtherSimpleModel, DeepLinkModel1, DeepLinkModel2,
NullableFKModel, BasicModel, UniqueTestModel, UniqueTogetherTestModel,
RelatedModel, O2OModel, M2MModel, ThroughModel, M2MModelThrough)
-class SimpleAutoFixture(AutoFixture):
+class SimpleMockup(Mockup):
name = generators.StaticGenerator('foo')
@@ -22,12 +22,12 @@ def assertEqualOr(self, first, second, fallback):
self.fail()
def test_create(self):
- filler = AutoFixture(BasicModel)
+ filler = Mockup(BasicModel)
filler.create(10)
self.assertEqual(BasicModel.objects.count(), 10)
def test_constraints(self):
- filler = AutoFixture(BasicModel)
+ filler = Mockup(BasicModel)
for obj in filler.create(100):
self.assertTrue(len(obj.chars) > 0)
self.assertEqual(type(obj.chars), unicode)
@@ -57,7 +57,7 @@ def test_constraints(self):
def test_field_generators(self):
int_value = 1
char_values = (u'a', u'b')
- filler = AutoFixture(
+ filler = Mockup(
BasicModel,
field_generators={
'intfield': generators.StaticGenerator(1),
@@ -72,15 +72,15 @@ def test_field_generators(self):
class TestRelations(TestCase):
def test_generate_foreignkeys(self):
- filler = AutoFixture(
+ filler = Mockup(
RelatedModel,
generate_fk=True)
for obj in filler.create(100):
self.assertEqual(obj.related.__class__, BasicModel)
self.assertEqual(obj.limitedfk.name, 'foo')
def test_deep_generate_foreignkeys(self):
- filler = AutoFixture(
+ filler = Mockup(
DeepLinkModel2,
generate_fk=True)
for obj in filler.create(10):
@@ -89,7 +89,7 @@ def test_deep_generate_foreignkeys(self):
self.assertEqual(obj.related.related2.__class__, SimpleModel)
def test_deep_generate_foreignkeys2(self):
- filler = AutoFixture(
+ filler = Mockup(
DeepLinkModel2,
follow_fk=False,
generate_fk=('related', 'related__related'))
@@ -99,35 +99,35 @@ def test_deep_generate_foreignkeys2(self):
self.assertEqual(obj.related.related2, None)
def test_generate_only_some_foreignkeys(self):
- filler = AutoFixture(
+ filler = Mockup(
RelatedModel,
generate_fk=('related',))
for obj in filler.create(100):
self.assertEqual(obj.related.__class__, BasicModel)
self.assertEqual(obj.limitedfk, None)
def test_follow_foreignkeys(self):
- related = AutoFixture(BasicModel).create()[0]
+ related = Mockup(BasicModel).create()[0]
self.assertEqual(BasicModel.objects.count(), 1)
simple = SimpleModel.objects.create(name='foo')
simple2 = SimpleModel.objects.create(name='bar')
- filler = AutoFixture(
+ filler = Mockup(
RelatedModel,
follow_fk=True)
for obj in filler.create(100):
self.assertEqual(obj.related, related)
self.assertEqual(obj.limitedfk, simple)
def test_follow_only_some_foreignkeys(self):
- related = AutoFixture(BasicModel).create()[0]
+ related = Mockup(BasicModel).create()[0]
self.assertEqual(BasicModel.objects.count(), 1)
simple = SimpleModel.objects.create(name='foo')
simple2 = SimpleModel.objects.create(name='bar')
- filler = AutoFixture(
+ filler = Mockup(
RelatedModel,
follow_fk=('related',))
for obj in filler.create(100):
@@ -136,7 +136,7 @@ def test_follow_only_some_foreignkeys(self):
def test_follow_fk_for_o2o(self):
# OneToOneField is the same as a ForeignKey with unique=True
- filler = AutoFixture(O2OModel, follow_fk=True)
+ filler = Mockup(O2OModel, follow_fk=True)
simple = SimpleModel.objects.create()
obj = filler.create()[0]
@@ -146,7 +146,7 @@ def test_follow_fk_for_o2o(self):
def test_generate_fk_for_o2o(self):
# OneToOneField is the same as a ForeignKey with unique=True
- filler = AutoFixture(O2OModel, generate_fk=True)
+ filler = Mockup(O2OModel, generate_fk=True)
all_o2o = set()
for obj in filler.create(10):
@@ -155,22 +155,22 @@ def test_generate_fk_for_o2o(self):
self.assertEqual(set(SimpleModel.objects.all()), all_o2o)
def test_follow_m2m(self):
- related = AutoFixture(SimpleModel).create()[0]
+ related = Mockup(SimpleModel).create()[0]
self.assertEqual(SimpleModel.objects.count(), 1)
- filler = AutoFixture(
+ filler = Mockup(
M2MModel,
follow_m2m=(2, 10))
for obj in filler.create(10):
self.assertEqual(list(obj.m2m.all()), [related])
def test_follow_only_some_m2m(self):
- related = AutoFixture(SimpleModel).create()[0]
+ related = Mockup(SimpleModel).create()[0]
self.assertEqual(SimpleModel.objects.count(), 1)
- other_related = AutoFixture(OtherSimpleModel).create()[0]
+ other_related = Mockup(OtherSimpleModel).create()[0]
self.assertEqual(OtherSimpleModel.objects.count(), 1)
- filler = AutoFixture(
+ filler = Mockup(
M2MModel,
follow_m2m={
'm2m': (2, 10),
@@ -180,7 +180,7 @@ def test_follow_only_some_m2m(self):
self.assertEqual(list(obj.secondm2m.all()), [])
def test_generate_m2m(self):
- filler = AutoFixture(
+ filler = Mockup(
M2MModel,
generate_m2m=(1, 5))
all_m2m = set()
@@ -194,7 +194,7 @@ def test_generate_m2m(self):
self.assertEqual(OtherSimpleModel.objects.count(), len(all_secondm2m))
def test_generate_only_some_m2m(self):
- filler = AutoFixture(
+ filler = Mockup(
M2MModel,
generate_m2m={
'm2m': (1, 5),
@@ -210,7 +210,7 @@ def test_generate_only_some_m2m(self):
self.assertEqual(OtherSimpleModel.objects.count(), len(all_secondm2m))
def test_generate_m2m_with_intermediary_model(self):
- filler = AutoFixture(
+ filler = Mockup(
M2MModelThrough,
generate_m2m=(1, 5))
all_m2m = set()
@@ -222,14 +222,14 @@ def test_generate_m2m_with_intermediary_model(self):
class TestUniqueConstraints(TestCase):
def test_unique_field(self):
- filler = AutoFixture(UniqueTestModel)
+ filler = Mockup(UniqueTestModel)
count = len(filler.model._meta.
get_field_by_name('choice1')[0].choices)
for obj in filler.create(count):
pass
def test_unique_together(self):
- filler = AutoFixture(UniqueTogetherTestModel)
+ filler = Mockup(UniqueTogetherTestModel)
count1 = len(filler.model._meta.
get_field_by_name('choice1')[0].choices)
count2 = len(filler.model._meta.
@@ -240,7 +240,7 @@ def test_unique_together(self):
class TestGenerators(TestCase):
def test_instance_selector(self):
- AutoFixture(SimpleModel).create(10)
+ Mockup(SimpleModel).create(10)
result = generators.InstanceSelector(SimpleModel).generate()
self.assertEqual(result.__class__, SimpleModel)
@@ -333,46 +333,46 @@ def test_inherit_always_true_value(self):
class TestRegistry(TestCase):
def setUp(self):
- self.original_registry = autofixture.helpers._registry
- autofixture.helpers._registry = {}
+ self.original_registry = mockups.helpers._registry
+ mockups.helpers._registry = {}
def tearDown(self):
- autofixture.helpers._registry = self.original_registry
+ mockups.helpers._registry = self.original_registry
def test_registration(self):
- autofixture.register(SimpleModel, SimpleAutoFixture)
- self.assertTrue(SimpleModel in autofixture.helpers._registry)
- self.assertEqual(autofixture.helpers._registry[SimpleModel], SimpleAutoFixture)
+ mockups.register(SimpleModel, SimpleMockup)
+ self.assertTrue(SimpleModel in mockups.helpers._registry)
+ self.assertEqual(mockups.helpers._registry[SimpleModel], SimpleMockup)
def test_create(self):
- autofixture.register(SimpleModel, SimpleAutoFixture)
- for obj in autofixture.create(SimpleModel, 10):
+ mockups.register(SimpleModel, SimpleMockup)
+ for obj in mockups.create(SimpleModel, 10):
self.assertEqual(obj.name, 'foo')
- obj = autofixture.create_one(SimpleModel)
+ obj = mockups.create_one(SimpleModel)
self.assertEqual(obj.name, 'foo')
def test_overwrite_attributes(self):
- autofixture.register(SimpleModel, SimpleAutoFixture)
- for obj in autofixture.create(
+ mockups.register(SimpleModel, SimpleMockup)
+ for obj in mockups.create(
SimpleModel, 10, field_generators={'name': generators.StaticGenerator('bar')}):
self.assertEqual(obj.name, 'bar')
- obj = autofixture.create_one(
+ obj = mockups.create_one(
SimpleModel, field_generators={'name': generators.StaticGenerator('bar')})
self.assertEqual(obj.name, 'bar')
-class TestAutofixtureAPI(TestCase):
+class TestMockupAPI(TestCase):
def setUp(self):
- self.original_registry = autofixture.helpers._registry
- autofixture.helpers._registry = {}
+ self.original_registry = mockups.helpers._registry
+ mockups.helpers._registry = {}
def tearDown(self):
- autofixture.helpers._registry = self.original_registry
+ mockups.helpers._registry = self.original_registry
class TestManagementCommand(TestCase):
def setUp(self):
- from autofixture.management.commands.loadtestdata import Command
+ from mockups.management.commands.mockups import Command
self.command = Command()
self.options = {
'no_follow_fk': None,
@@ -383,28 +383,28 @@ def setUp(self):
'verbosity': '0',
'use': '',
}
- self.original_registry = autofixture.helpers._registry
- autofixture.helpers._registry = {}
+ self.original_registry = mockups.helpers._registry
+ mockups.helpers._registry = {}
def tearDown(self):
- autofixture.helpers._registry = self.original_registry
+ mockups.helpers._registry = self.original_registry
def test_basic(self):
models = ()
# empty attributes are allowed
self.command.handle(*models, **self.options)
self.assertEqual(SimpleModel.objects.count(), 0)
- models = ('autofixture_test.SimpleModel:1',)
+ models = ('mockups_test.SimpleModel:1',)
self.command.handle(*models, **self.options)
self.assertEqual(SimpleModel.objects.count(), 1)
- models = ('autofixture_test.SimpleModel:5',)
+ models = ('mockups_test.SimpleModel:5',)
self.command.handle(*models, **self.options)
self.assertEqual(SimpleModel.objects.count(), 6)
def test_generate_fk(self):
- models = ('autofixture_test.DeepLinkModel2:1',)
+ models = ('mockups_test.DeepLinkModel2:1',)
self.options['generate_fk'] = 'related,related__related'
self.command.handle(*models, **self.options)
obj = DeepLinkModel2.objects.get()
@@ -413,7 +413,7 @@ def test_generate_fk(self):
self.assertEqual(obj.related.related2, obj.related.related)
def test_generate_fk_with_no_follow(self):
- models = ('autofixture_test.DeepLinkModel2:1',)
+ models = ('mockups_test.DeepLinkModel2:1',)
self.options['generate_fk'] = 'related,related__related'
self.options['no_follow_fk'] = True
self.command.handle(*models, **self.options)
@@ -423,7 +423,7 @@ def test_generate_fk_with_no_follow(self):
self.assertEqual(obj.related.related2, None)
def test_generate_fk_with_ALL(self):
- models = ('autofixture_test.DeepLinkModel2:1',)
+ models = ('mockups_test.DeepLinkModel2:1',)
self.options['generate_fk'] = 'ALL'
self.command.handle(*models, **self.options)
obj = DeepLinkModel2.objects.get()
@@ -433,19 +433,19 @@ def test_generate_fk_with_ALL(self):
self.assertTrue(obj.related.related != obj.related.related2)
def test_no_follow_m2m(self):
- AutoFixture(SimpleModel).create(1)
+ Mockup(SimpleModel).create(1)
- models = ('autofixture_test.NullableFKModel:1',)
+ models = ('mockups_test.NullableFKModel:1',)
self.options['no_follow_m2m'] = True
self.command.handle(*models, **self.options)
obj = NullableFKModel.objects.get()
self.assertEqual(obj.m2m.count(), 0)
def test_follow_m2m(self):
- AutoFixture(SimpleModel).create(10)
- AutoFixture(OtherSimpleModel).create(10)
+ Mockup(SimpleModel).create(10)
+ Mockup(OtherSimpleModel).create(10)
- models = ('autofixture_test.M2MModel:25',)
+ models = ('mockups_test.M2MModel:25',)
self.options['follow_m2m'] = 'm2m:3:3,secondm2m:0:10'
self.command.handle(*models, **self.options)
@@ -454,7 +454,7 @@ def test_follow_m2m(self):
self.assertTrue(0 <= obj.secondm2m.count() <= 10)
def test_generate_m2m(self):
- models = ('autofixture_test.M2MModel:10',)
+ models = ('mockups_test.M2MModel:10',)
self.options['generate_m2m'] = 'm2m:1:1,secondm2m:2:5'
self.command.handle(*models, **self.options)
@@ -470,15 +470,15 @@ def test_generate_m2m(self):
self.assertEqual(all_secondm2m, set(OtherSimpleModel.objects.all()))
def test_using_registry(self):
- autofixture.register(SimpleModel, SimpleAutoFixture)
- models = ('autofixture_test.SimpleModel:10',)
+ mockups.register(SimpleModel, SimpleMockup)
+ models = ('mockups_test.SimpleModel:10',)
self.command.handle(*models, **self.options)
for obj in SimpleModel.objects.all():
self.assertEqual(obj.name, 'foo')
def test_use_option(self):
- self.options['use'] = 'autofixture_tests.autofixture_test.tests.SimpleAutoFixture'
- models = ('autofixture_test.SimpleModel:10',)
+ self.options['use'] = 'mockups_tests.mockups_test.tests.SimpleMockup'
+ models = ('mockups_test.SimpleModel:10',)
self.command.handle(*models, **self.options)
for obj in SimpleModel.objects.all():
self.assertEqual(obj.name, 'foo')
View
0 autofixture/models.py → mockups_tests/models.py
File renamed without changes.
View
0 mockups_tests/sample_app/__init__.py
No changes.
View
2 autofixture_tests/sample_app/admin.py → mockups_tests/sample_app/admin.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
-from autofixture_tests.sample_app.models import Post
+from mockups_tests.sample_app.models import Post
admin.site.register(Post)
View
0 autofixture_tests/sample_app/models.py → mockups_tests/sample_app/models.py
File renamed without changes.
View
4 autofixture_tests/urls.py → mockups_tests/urls.py
@@ -12,8 +12,8 @@ def handle404(request):
def handle500(request):
return HttpResponse('500')
-handler404 = 'autofixture_tests.urls.handle404'
-handler500 = 'autofixture_tests.urls.handle500'
+handler404 = 'mockups_tests.urls.handle404'
+handler500 = 'mockups_tests.urls.handle500'
urlpatterns = patterns('',
View
6 runtests.py
@@ -12,9 +12,9 @@
def runtests(*args):
failures = run_tests(
args or [
- 'autofixture',
- 'autofixture_tests',
- 'autofixture_test',
+ 'mockups',
+ 'mockups_tests',
+ 'mockups_test',
'generator_test',
'sample_app',
],
View
16 settings.py
@@ -37,7 +37,7 @@
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'autofixture_tests', 'media')
+MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'mockups_tests', 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
@@ -66,10 +66,10 @@
'django.middleware.doc.XViewMiddleware',
)
-ROOT_URLCONF = 'autofixture_tests.urls'
+ROOT_URLCONF = 'mockups_tests.urls'
TEMPLATE_DIRS = (
- os.path.join(PROJECT_ROOT, 'autofixture_tests', 'templates'),
+ os.path.join(PROJECT_ROOT, 'mockups_tests', 'templates'),
)
INSTALLED_APPS = (
@@ -81,11 +81,11 @@
'django_extensions',
- 'autofixture_tests',
- 'autofixture_tests.sample_app',
- 'autofixture_tests.autofixture_test',
- 'autofixture_tests.generator_test',
- 'autofixture',
+ 'mockups_tests',
+ 'mockups_tests.sample_app',
+ 'mockups_tests.mockups_test',
+ 'mockups_tests.generator_test',
+ 'mockups',
)
TEMPLATE_CONTEXT_PROCESSORS = (
View
18 setup.py
@@ -31,14 +31,14 @@ def split(self, *args, **kw):
setup(
- name = 'django-autofixture',
- version = '0.2.5',
- url = 'https://github.com/gregmuellegger/django-autofixture',
+ name = 'django-mockups',
+ version = '0.2.6',
+ url = 'https://github.com/sorl/django-mockups',
license = 'BSD',
- description = 'Provides tools to auto generate test data.',
+ description = 'Provides tools to auto generate content.',
long_description = long_description,
- author = UltraMagicString('Gregor Müllegger'),
- author_email = 'gregor@muellegger.de',
+ author = UltraMagicString('Mikko Hellsing'),
+ author_email = 'mikko@aino.se',
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
@@ -50,9 +50,9 @@ def split(self, *args, **kw):
'Programming Language :: Python',
],
packages = [
- 'autofixture',
- 'autofixture.management',
- 'autofixture.management.commands'],
+ 'mockups',
+ 'mockups.management',
+ 'mockups.management.commands'],
install_requires = ['setuptools'],
test_suite = 'runtests.runtests',
)

0 comments on commit f70bcfe

Please sign in to comment.
Something went wrong with that request. Please try again.