Reference¶
WagtailPageTests¶
-
class
wagtailtestutils.utils.WagtailPageTests[source]¶ -
assertCanCreateAt(parent_model, child_model, msg=None)[source]¶ Assert a particular child Page type can be created under a parent Page type.
parent_modelandchild_modelshould be the Page classes being tested.Example:
# You can create a ContentPage under a HomePage self.assertCanCreateAt(HomePage, ContentPage)
-
assertCanNotCreateAt(parent_model, child_model, msg=None)[source]¶ Assert a particular child Page type can not be created under a parent Page type.
parent_modelandchild_modelshould be the Page classes being tested.Example:
# You can not create a ContentPage under an EventPage self.assertCanNotCreateAt(EventPage, ContentPage)
-
assertCanCreate(parent, child_model, data, msg=None)[source]¶ Assert that a child of the given Page type can be created under the parent, using the supplied POST data.
parentshould be a Page instance, andchild_modelshould be a Page subclass.datashould be a dict that will be POSTed at the Wagtail admin Page creation method.Example:
# Get the HomePage root_page = HomePage.objects.get(pk=2) # Assert that a ContentPage can be made here, with this POST data self.assertCanCreate(root_page, ContentPage, { 'title': 'About us', 'body': 'Lorem ipsum dolor sit amet')
-
assertAllowedParentPageTypes(child_model, parent_models, msg=None)[source]¶ Test that the only page types that
child_modelcan be created under areparent_models.The list of allowed parent models may differ from those set in
Page.parent_page_types, if the parent models have setPage.subpage_types.Example:
# A ContentPage can only be created under a HomePage # or another ContentPage self.assertAllowedParentPageTypes( ContentPage, {HomePage, ContentPage}) # An EventPage can only be created under an EventIndex self.assertAllowedParentPageTypes( EventPage, {EventIndex})
-
assertAllowedSubpageTypes(parent_model, child_models, msg=None)[source]¶ Test that the only page types that can be created under
parent_modelarechild_models.The list of allowed child models may differ from those set in
Page.subpage_types, if the child models have setPage.parent_page_types.Example:
# A ContentPage can only have other ContentPage children self.assertAllowedSubpageTypes( ContentPage, {ContentPage}) # A HomePage can have ContentPage and EventIndex children self.assertAllowedParentPageTypes( HomePage, {ContentPage, EventIndex})
-