'helper function to check the expected_granted_pages are
not in the restricted_pages list and
all visible pages are in the expected_granted_pages'

def assertGrantedVisibility(self, all_pages, expected_granted_pages, username=None):

    user = None
    if (username is not None):
        if (get_user_model().USERNAME_FIELD == 'email'):
            username = (username + '@django-cms.org')
        query = dict()
        query[(get_user_model().USERNAME_FIELD + '__iexact')] = username
        user = get_user_model().objects.get(**query)
    request = self.get_request(user)
    visible_page_ids = get_visible_pages(request, all_pages, self.site)
    public_page_ids = Page.objects.drafts().filter(title_set__title__in=expected_granted_pages).values_list('id', flat=True)
    self.assertEqual(len(visible_page_ids), len(expected_granted_pages))
    restricted_pages = Page.objects.public().exclude(title_set__title__in=expected_granted_pages).values_list('id', flat=True)
    self.assertNodeMemberships(visible_page_ids, restricted_pages, public_page_ids)
