from django.test import TestCase

from ocyan.plugin.wagtail.blocks import HeadedPagelistBlock
from ocyan.plugin.wagtail.models import AbstractBasePage


class AbstractBasePageTestCase(TestCase):
    def test_is_creatable(self):
        """AbstractBasePage should not be creatable.
        We just use it for generic fields, ie metadata.
        """
        self.assertFalse(AbstractBasePage.is_creatable)


class HeadedPagelistBlockTestCase(TestCase):
    def test_nonexisting_page(self):
        block = HeadedPagelistBlock()
        # page will be None if the referenced page is deleted
        block.get_context({"page": None})
