aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Expand)AuthorAge
* Fix a17b036: Error messages have moved.Raphaël Barrois2016-04-07
* Merge pull request #256 from koterpillar/cyclic-definition-rescue•••Don't leave AttributeBuilder in an inconsistent state on exceptionsRaphaël Barrois2016-04-07
|\
| * Test LazyValues handling CyclicDefinitionErrorAlexey Kotlyarov2015-12-08
* | Add documentation and test for subfactory using "factory_parent" attribute•••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. Samuel Paccoud2016-04-03
* | Add Traits (Closes #251).•••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. Raphaël Barrois2016-04-02
* | Add a new Params section to factories.•••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 Raphaël Barrois2016-04-02
* | Refactor: move error defs to a dedicated module.Raphaël Barrois2016-04-02
* | django: Clarify behavior around ``abstract=True``•••See issue #280. Raphaël Barrois2016-03-12
* | Add test for "build as dict" trick (See #68).Raphaël Barrois2016-02-23
* | factory: LazyFunction to just call a function in the simplest case•••No need to wrap it in a lambda to strip the object argument from LazyAttribute or the sequence argument from Sequence. Hervé Cauwelier2016-02-12
* | Merge remote-tracking branch 'minjung/flushing_sqlalchemy_factory'Raphaël Barrois2016-02-10
|\ \
| * | added unittests for rbarrois/factory_boy#81Alejandro2016-01-07
| |/
* | Fix "no FloatOperation test", invalid until PY3Raphaël Barrois2016-02-10
* | fuzzy: Fix decimal.FloatOperation warning (Closes #261)•••Under Python 2.7+, the previous versions was directly casting fuzzy Decimal values into a float, which led to warnings in code trying to avoid such conversions in its tested code. Since we're just building random values, that behavior led to false positives or required jumping through weird hoops whenever a FuzzyDecimal was used. We now go trough a ``str()`` call to avoid such warnings. Raphaël Barrois2016-02-10
* | Clarify the use of SelfAttribute in RelatedFactory (Closes #264)Raphaël Barrois2016-02-09
|/
* add a way to add custom providers to Faker•••factory_boy wraps faker and it stores Faker generators in a 'private' _FAKER_REGISTRY class attribute dict. There needs to be a way to extend the Faker generators with additional custom providers (without having to access _FAKER_REGISTRY directly). This commit adds a (factory_boy) Faker.add_provider class method which calls Faker's own `add_provider` method on internally stored (via _FAKER_REGISTRY) Faker generators. Ionuț Arțăriși2015-10-20
* Improve debug logging efficiency (Closes #155).•••As suggested by @adamchainz, use lazy computation of args/kwargs pprint to only perform complex computation when running with debug. Raphaël Barrois2015-07-11
* Fix mute_signals behavior for signals with caching•••Connecting signals (with use_caching=True) inside mute_signals was breaking unmute on exit. Paused receivers were not running. This was caused by signal cache not being restored after unpatching. Workaround is to clear signal cache on exit. Fixes #212 Ilya Baryshev2015-07-05
* Properly handle custom Django managers (Closes #201).•••The actual behavior of Django with custom managers and inherited abstract models is rather complex, so this had to be adapted to the actual Django source code. Raphaël Barrois2015-05-31
* Add lazy loading to factory.Iterator.•••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. Raphaël Barrois2015-05-24
* Add factory.Faker()•••This relies on the ``fake-factory`` library, and provides realistic random values for most field types. Raphaël Barrois2015-05-22
* Add Meta.rename to handle name conflicts (See #206).•••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. Raphaël Barrois2015-05-20
* Fix typo.Raphaël Barrois2015-04-27
* Allow skipping Mongo tests.Raphaël Barrois2015-04-27
* Fix test startup for Django==1.6Raphaël Barrois2015-04-27
* Clarify .build() issue with Django>1.8 (Ref #198).•••From 1.8 onwards, this crashes: >>> a = MyModel() # Don't save >>> b = MyOtherModel(fkey_to_mymodel=a) In turn, it breaks: class MyModelFactory(factory.django.DjangoModelFactory): class Meta: model = MyModel class MyOtherModelFactory(factory.django.DjangoModelFactory): class Meta: model = MyOtherModel fkey_to_mymodel = factory.SubFactory(MyModelFactory) MyOtherModelFactory.build() # Breaks The error message is: Cannot assign "MyModel()": "MyModel" instance isn't saved in the database. See https://code.djangoproject.com/ticket/10811 for details. Raphaël Barrois2015-04-25
* Remove warnings with Django 1.7 (Closes #195).•••Builds upon pull request by @shinuza: - Properly import ``get_model`` - Run ``django.setup()`` before importing any models. Raphaël Barrois2015-04-14
* test_mongoengine: fix typoRaphaël Barrois2015-04-12
* mongoengine: allow tuning the server timeout.•••So that it doesn't fail on ci... Raphaël Barrois2015-04-12
* Fix tests with latest pymongo/mongoengine.•••mongoengine>=0.9.0 and pymongo>=2.1 require extra parameters: - The server connection timeout was set too high - We have to define a ``read_preference``. Raphaël Barrois2015-04-12
* Fix imports for Django 1.8Raphaël Barrois2015-04-02
* Fix custom queryset tests for Django<1.7Raphaël Barrois2015-03-27
* Support declarations in FileField/ImageField.•••Previously, the declarations (``factory.Sequence`` & co) weren't properly computed. Raphaël Barrois2015-03-27
* Respect default manager in DjangoModelFactory (Closes #192).•••The previous version tries to use ``cls._default_manager`` all the time, which breaks with ``manager.using(db_name)``. Raphaël Barrois2015-03-27
* Update header years.Raphaël Barrois2015-03-26
* Turn FileField/ImageField into normal fields (Closes #141).•••Previously, they ran as post_generation hooks, meaning that they couldn't be checked in a model's ``save()`` method, for instance. Raphaël Barrois2015-03-26
* Remove limitations of factory.StubFactory (Closes #131).•••``StubFactory.build()`` is now supported, and maps to ``StubFactory.stub()``. Raphaël Barrois2015-03-26
* Add support for multidb with Django (Closes #171).•••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. Raphaël Barrois2015-03-26
* Fix issues between mute_signals() and factory inheritance (Closes #183).•••Previously, if a factory was decorated with ``@mute_signals`` and one of its descendant called another one of its descendant, signals weren't unmuted properly. Raphaël Barrois2015-03-26
* Allow lazy evaluation of FuzzyChoice's iterators (Closes #184).•••This allows the following idiom: ``user = factory.fuzzy.FuzzyChoice(User.objects.all())`` Previously, the ``User.objects.all()`` queryset would have been evaluated *at import time*; it is now evaluated with the first use of the ``FuzzyChoice``. Raphaël Barrois2015-03-26
* Enable resetting factory.fuzzy's random generator (Closes #175, #185).•••Users may now call ``factory.fuzzy.get_random_state()`` to retrieve the current random generator's state (isolated from the one used in Python's ``random``). That state can then be reinjected with ``factory.fuzzy.set_random_state(state)``. Raphaël Barrois2015-02-18
* Remove deprecated features.•••This disables the ``FACTORY_FOR`` syntax and related parameters, that should be declared through ``class Meta``. Raphaël Barrois2014-11-18
* Remove automagic pk-based sequence setup•••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()``. Raphaël Barrois2014-11-16
* Add tests for self-referential models (See #173).Raphaël Barrois2014-11-02
* Fix support for Django 1.7.Raphaël Barrois2014-09-03
* Fix test running without django (Closes #161).Raphaël Barrois2014-09-03
* tests: Update to Django new 'duplicate file' mechanism.Raphaël Barrois2014-08-21
* Fix declaration inheritance.Raphaël Barrois2014-06-23
* Provide readable errors when Meta.model isn't set (Closes #137).Raphaël Barrois2014-06-21
* Fix test_deprecation test.Raphaël Barrois2014-05-18