You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The testing code that is there now returns an error:
django.db.utils.IntegrityError: null value in column "root_page_id" of relation "wagtailcore_site" violates not-null constraint
DETAIL: Failing row contains (1, testserver, 80, testserver, null, t).
The reason being that root = Page.get_first_root_node() does not actually return anything.
If we change the code to the following (just an example):
from wagtail.models import Locale, Site
from wagtail.test.utils import WagtailPageTestCase
...
class ContentPageTests(WagtailPageTestCase):
@classmethod
def setUpTestData(cls):
# create a home page
locale = Locale.objects.create(language_code="nl")
cls.home_page = ContentPage.objects.create(
title="Home Page", slug="home", locale=locale, depth=1, path="0001"
)
# Create a site with the home page set as the root
cls.site = Site.objects.create(is_default_site=True, root_page=cls.home_page)
It works! (But not sure that it is even correct?)
Working on this
I could of course update the docs myself but I'm not sure if we maybe are missing something?
BTW, thanks for all your hard work, keep it up!
The text was updated successfully, but these errors were encountered:
Trying to write tests for a few Wagtail 6 websites and looking at https://docs.wagtail.org/en/stable/advanced_topics/testing.html#creating-page-objects-within-tests, it seems this code is maybe old?
Pertinent section of the Wagtail docs
https://docs.wagtail.org/en/stable/advanced_topics/testing.html#creating-page-objects-within-tests
Details
The testing code that is there now returns an error:
The reason being that
root = Page.get_first_root_node()
does not actually return anything.If we change the code to the following (just an example):
It works! (But not sure that it is even correct?)
Working on this
I could of course update the docs myself but I'm not sure if we maybe are missing something?
BTW, thanks for all your hard work, keep it up!
The text was updated successfully, but these errors were encountered: