Fixed #20579 -- Improved TransactionTestCase.available_apps. #1261

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Owner

aaugustin commented Jun 11, 2013

Also moved its documentation to the 'advanced' section. It doesn't
belong to the 'overview'. Same for TransactionTestCase.reset_sequences.

When available_apps is set, after a TransactionTestCase, the database
is now totally empty. post_syncdb is fired at the beginning of the next
TransactionTestCase.

Refs #20483.

Fixed #20579 -- Improved TransactionTestCase.available_apps.
Also moved its documentation to the 'advanced' section. It doesn't
belong to the 'overview'. Same for TransactionTestCase.reset_sequences.

When available_apps is set, after a TransactionTestCase, the database
is now totally empty. post_syncdb is fired at the beginning of the next
TransactionTestCase.

Refs #20483.
+ calls :djadmin:`flush` to reset the database state. This empties all the
+ tables and emits the :data:`~django.db.models.signals.post_syncdb` signal,
+ which re-creates one content type and three permissions for each model.
+ This gets expensive proportionnally to the number of models.
@timgraham

timgraham Jun 12, 2013

Owner

proportionally

+
+ - :data:`~django.db.models.signals.post_syncdb` is fired before each
+ test to create the content types and permissions for models in available
+ apps, in case they're missing.
@timgraham

timgraham Jun 12, 2013

Owner

available apps -> "available_apps"? comma not necessary on this line

+ apps, in case they're missing.
+ - After each test, Django empties only the tables corresponding to models
+ in available apps. However, at the database level, truncation may
+ cascade to related models in unavailable apps. Furthermore
@timgraham

timgraham Jun 12, 2013

Owner

I guess "available apps" above is fine given the use of "unavailable apps" here

+ same as after a ``TestCase``: it's missing the rows created by listeners
+ to :data:`~django.db.models.signals.post_syncdb`. Considering the
+ :ref:`order in which tests are executed <order-of-tests>`, this isn't an
+ issue, provided all ``TransactionTestCase`` in a given test suite use
@timgraham

timgraham Jun 12, 2013

Owner

I think what you mean is: "provided all (or none) TransactionTestCases in a give test suite use available_apps.

Owner

aaugustin commented Jun 12, 2013

Merged.

@aaugustin aaugustin closed this Jun 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment