コード例 #1
0
    def test_page_models_have_search_fields(self):
        """
        All page content types should have search_fields.
        This doesn't tell us if we've set them correctly
        but it ensures we've done something. 
        """
        # We get rid of the first element because it is a wagtailcore.Page
        content_types = Page.allowed_subpage_models()[1:]
        page_search_fields = Page.search_fields
        base_page_search_fields = BasePage.search_fields
        default_search_fields = set(page_search_fields + base_page_search_fields)
        ignore = set(['AlertPage', 'AlertIndexPage', 'ConferenceIndexPage', 'FindingAidsPage', 'GroupMeetingMinutesIndexPage', \
                      'GroupReportsIndexPage', 'HomePage', 'IntranetFormPage', 'IntranetHomePage', 'IntranetUnitsReportsIndexPage', \
                      'ProjectIndexPage', 'GroupMeetingMinutesPage', 'GroupReportsPage', 'IntranetUnitsReportsPage'])
        no_search_fields = set([])
        for page_type in content_types:
            if not len(set(page_type.search_fields)) > len(default_search_fields) and not page_type.__name__ in ignore:
                no_search_fields.add(page_type.__name__)

        self.assertEqual(len(no_search_fields), 0, 'The following content types don\'t have a search_fields declaration or their search_field declaration is not extending a base_class search_fields attribute: ' + str(no_search_fields))
コード例 #2
0
    def test_page_models_have_subpage_types(self):
        """
        All page content types should have subpage_types 
        explicitly set. This test won't tell us if they're 
        set correctly but it will make sure we've at least
        done something.
        """
        # We get rid of the first element because it is a wagtailcore.Page
        content_types = Page.allowed_subpage_models()[1:]
        #number_of_content_types = len(content_types)
 
        no_subpagetypes = set([])
        for page_type in content_types:
            #num = len(page_type.allowed_subpage_models())
            try:
                #self.assertNotEqual(num, number_of_content_types, 'This content type is missing a subpage_types declaration')
                #assert page_type.subpage_types, 'This content type is missing a subpage_types declaration'
                page_type.subpage_types
            except:
                no_subpagetypes.add(page_type.__name__)

        self.assertEqual(len(no_subpagetypes), 0, 'The following content types don\'t have a subpages_type declaration: ' + str(no_subpagetypes))