summaryrefslogtreecommitdiff
path: root/tests/test_using.py
Commit message (Collapse)AuthorAge
* Add documentation and test for subfactory using "factory_parent" attributeSamuel Paccoud2016-04-03
| | | | | | | | | Add documentation on how to use a LazyAttribute in a SubFactory and poke the "factory_parent" attribute to indirectly derive the value of a field on the child factory from a field on the parent factory. This commit adds an example to recipes that explains how it can be done. It also adds a test to make sure that this feature continues to work as is now described in the documentation.
* Add Traits (Closes #251).Raphaël Barrois2016-04-02
| | | | | | Based on a boolean flag, those will alter the definitions of the current factory, taking precedence over pre-defined behavior but overridden by callsite-level arguments.
* Add a new Params section to factories.Raphaël Barrois2016-04-02
| | | | | | | | | | | | This handles parameters that alter the declarations of a factory. A few technical notes: - A parameter's outcome may alter other parameters - In order to fix that, we perform a (simple) cyclic definition detection at class declaration time. - Parameters may only be either naked values or ComplexParameter subclasses - Parameters are never passed to the underlying class
* Add test for "build as dict" trick (See #68).Raphaël Barrois2016-02-23
|
* Clarify the use of SelfAttribute in RelatedFactory (Closes #264)Raphaël Barrois2016-02-09
|
* Add lazy loading to factory.Iterator.Raphaël Barrois2015-05-24
| | | | | | | | | | | factory.Iterator no longers begins iteration of its argument on declaration, since this behavior may trigger database query when that argument is, for instance, a Django queryset. The ``factory.Iterator``'s argument will only be called when the containing ``Factory`` is first evaluated; this means that factories using ``factory.Iterator(models.MyThingy.objects.all())`` will no longer call the database at import time.
* Add Meta.rename to handle name conflicts (See #206).Raphaël Barrois2015-05-20
| | | | | | Define ``Meta.rename = {'attrs': 'attributes'}`` if your model expects a ``attributes`` kwarg but you can't define it since it's already reserved by the ``Factory`` class.
* Update header years.Raphaël Barrois2015-03-26
|
* Add support for multidb with Django (Closes #171).Raphaël Barrois2015-03-26
| | | | | | | | | | | | | | The ``factory.django.DjangoModelFactory`` now takes an extra option: ``` class MyFactory(factory.django.DjangoModelFactory): class Meta: model = models.MyModel database = 'replica' ``` This will create all instances of ``models.Model`` in the ``'replica'`` database.
* Remove deprecated features.Raphaël Barrois2014-11-18
| | | | | This disables the ``FACTORY_FOR`` syntax and related parameters, that should be declared through ``class Meta``.
* Remove automagic pk-based sequence setupRaphaël Barrois2014-11-16
| | | | | | | | | | | | | | | | | | | | | | | | Related to issues #78, #92, #103, #111, #153, #170 The default value of all sequences is now 0; the automagic ``_setup_next_sequence`` behavior of Django/SQLAlchemy has been removed. This feature's only goal was to allow the following scenario: 1. Run a Python script that uses MyFactory.create() a couple of times (with a unique field based on the sequence counter) 2. Run the same Python script a second time Without the magical ``_setup_next_sequence``, the Sequence counter would be set to 0 at the beginning of each script run, so both runs would generate objects with the same values for the unique field ; thus conflicting and crashing. The above behavior having only a very limited use and bringing various issues (hitting the database on ``build()``, problems with non-integer or composite primary key columns, ...), it has been removed. It could still be emulated through custom ``_setup_next_sequence`` methods, or by calling ``MyFactory.reset_sequence()``.
* Add tests for self-referential models (See #173).Raphaël Barrois2014-11-02
|
* Fix declaration inheritance.Raphaël Barrois2014-06-23
|
* Rename hidden/arg_parameters to exclude/inline_args.Raphaël Barrois2014-05-18
|
* Rename 'target' to 'model'.Raphaël Barrois2014-05-18
|
* Switch tests to class Meta.Raphaël Barrois2014-05-18
|
* LintRaphaël Barrois2013-09-24
|
* Properly handle Sequence & inheritance (Closes #93).Raphaël Barrois2013-09-17
| | | | | There was also a nasty bug: with class FactoryB(FactoryA), FactoryB's sequence counter started at the value of FactoryA's counter when FactoryB was first called.
* Fix coverageRaphaël Barrois2013-06-15
|
* Add tests for RelatedFactory extraction.Raphaël Barrois2013-06-15
|
* Move DjangoModelFactory / MogoFactory to their own modules.Raphaël Barrois2013-06-09
|
* Don't use objects.get_or_create() unless required.Raphaël Barrois2013-04-16
|
* Release v2.0.1v2.0.1Raphaël Barrois2013-04-16
|
* Add more tests for DjangoModelFactoryTestCase.Raphaël Barrois2013-04-16
|
* Add Dict/List declarations (Closes #18).Raphaël Barrois2013-04-15
|
* Allow overriding the sequence counter.Raphaël Barrois2013-04-15
|
* Nit: cleanup name of test methods.Raphaël Barrois2013-04-03
|
* Add support for get_or_create in DjangoModelFactory.Raphaël Barrois2013-04-02
|
* Add Factory.FACTORY_HIDDEN_ARGS.Raphaël Barrois2013-04-02
| | | | | Fields listed in this class attributes will be removed from the kwargs dict passed to the associated class for building/creation.
* Default Sequence.type to int (Closes #50).Raphaël Barrois2013-03-24
|
* Remove extract_prefix from post-generation hooks.Raphaël Barrois2013-03-11
| | | | Magic abuse is bad.
* Remove InfiniteIterator and infinite_iterator.Raphaël Barrois2013-03-11
| | | | Use Iterator/iterator instead.
* Remove building_function/creation_function.Raphaël Barrois2013-03-11
| | | | Stop defaulting to Django's .objects.create().
* Stop calling Foo.objects.create() when it doesn't break (Closes #23).Raphaël Barrois2013-03-05
| | | | | | | | | This will be properly fixed in v2.0.0; the current heuristic is: - If the user defined a custom _create method, use it - If he didn't, but the associated class has a objects attribute, use TheClass.objects.create(*args, **kwargs) - Otherwise, simply call TheClass(*args, **kwargs). Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add a 'after post_generation' hook to Factory.Raphaël Barrois2013-03-04
| | | | | | Use it in DjangoModelFactory to save objects again if a post_generation hook ran. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Get rid of the FACTORY_ABSTRACT rename.Raphaël Barrois2013-03-03
| | | | | | This was just adding noise to an already complex release. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve coverage.Raphaël Barrois2013-03-03
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Deprecate the extract_prefix option to PostGeneration.Raphaël Barrois2013-03-03
| | | | | | Introduces a new, call-less syntax for the @post_generation decorator. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Tests: move disable_warnings to its own class.Raphaël Barrois2013-03-03
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Improve Iterator and SubFactory declarations.Raphaël Barrois2013-03-03
| | | | | | | | | | | | * Iterator now cycles by default * Iterator can be provided with a custom getter * SubFactory accepts a factory import path as well Deprecates: * InfiniteIterator * CircularSubFactory Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add test for dual class/factory inheritance.Raphaël Barrois2013-02-27
| | | | | | If it works properly, this would make pylint happy. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Happy New Year!Raphaël Barrois2013-01-02
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Rename ABSTRACT_FACTORY to FACTORY_ABSTRACT.Raphaël Barrois2012-11-15
| | | | | | And add a deprecation warning too. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add an extension point for kwargs mangling.Raphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Mix SelfAttribute with ContainerAttribute.Raphaël Barrois2012-11-15
| | | | | | With a very simple syntax. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* [py3] Various python3-compatibility fixes.Raphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* [py3] Rename xrange to rangeRaphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* [py3] Disable 'scope bleeding' test on py3.Raphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* [py3] Remove calls to iteritems().Raphaël Barrois2012-11-15
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add support for passing non-kwarg parameters to factories.Raphaël Barrois2012-08-17
| | | | Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>