Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for background task behaviour in Wagtail 6.4 #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gasman
Copy link
Member

@gasman gasman commented Jan 20, 2025

In Wagtail 6.4 (wagtail/wagtail#12787), updating the search index and reference index after a database update are now handled as background tasks through the django-tasks library. In the default configuration, this happens at the end of the current transaction (if any), and since unit tests are typically wrapped in a transaction, we can no longer count on the results of database updates within tests being immediately visible in search and object usage queries. To ensure that these tasks are executed, we trigger the oncommit hooks via self.captureOnCommitCallbacks(execute=True).

In Wagtail 6.4 (wagtail/wagtail#12787), updating the search index and reference index after a database update are now handled as background tasks through the django-tasks library. In the default configuration, this happens at the end of the current transaction (if any), and since unit tests are typically wrapped in a transaction, we can no longer count on the results of database updates within tests being immediately visible in search and object usage queries. To ensure that these tasks are executed, we trigger the oncommit hooks via `self.captureOnCommitCallbacks(execute=True)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant