def test_sector_page_related_pages_serializer_has_pages(root_page, rf):
    related_page_one = InternationalArticlePageFactory(parent=root_page,
                                                       slug='one')
    related_page_two = InternationalArticlePageFactory(parent=root_page,
                                                       slug='two')
    related_page_three = InternationalArticlePageFactory(parent=root_page,
                                                         slug='three')
    case_study_cta_page = InternationalArticlePageFactory(parent=root_page,
                                                          slug="case_study")
    article = InternationalSectorPageFactory(
        parent=root_page,
        slug='article-slug',
        related_page_one=related_page_one,
        related_page_two=related_page_two,
        related_page_three=related_page_three,
        case_study_cta_page=case_study_cta_page)

    serializer = InternationalSectorPageSerializer(
        instance=article, context={'request': rf.get('/')})

    assert len(serializer.data['related_pages']) == 3
    cta_page = serializer.data['case_study_cta_page']
    assert 'title' in cta_page
    assert 'teaser' in cta_page
    assert 'thumbnail' in cta_page
def test_guide_landing_page_serializer_guide_list(root_page, image, rf):
    """
    The serializer for InternationalGuideLandingPage should include a list
    of decendants of type InternationalArticlePage only
    """
    page = InternationalGuideLandingPageFactory(
        parent=root_page,
        slug='page-slug',
        section_one_image=image,
        section_two_image=image,
    )

    InternationalArticlePageFactory(parent=page, slug='one')
    InternationalArticlePageFactory(parent=page, slug='two')
    # This page in not an InternationalArticlePage, so should not be included
    InternationalSectorPageFactory(parent=page, slug='three')

    serializer = InternationalGuideLandingPageSerializer(
        instance=page, context={'request': rf.get('/')})

    assert len(serializer.data['guides']) == 2
    for item in serializer.data['guides']:
        assert 'title' in item
        assert 'teaser' in item
        assert 'thumbnail' in item
def test_related_article_page_serializer_has_pages(parent_page_class,
                                                   serializer_class, root_page,
                                                   rf):
    related_page_one = InternationalArticlePageFactory(parent=root_page,
                                                       slug='one')
    related_page_two = InternationalArticlePageFactory(parent=root_page,
                                                       slug='two')
    related_page_three = InternationalArticlePageFactory(parent=root_page,
                                                         slug='three')
    article = parent_page_class(parent=root_page,
                                slug='article-slug',
                                related_page_one=related_page_one,
                                related_page_two=related_page_two,
                                related_page_three=related_page_three)

    serializer = serializer_class(instance=article,
                                  context={'request': rf.get('/')})

    assert len(serializer.data['related_pages']) == 3
示例#4
0
def test_page_paths(root_page):
    invest_app = InvestAppFactory(parent=root_page)
    invest_page_one = SectorLandingPageFactory(parent=invest_app)
    invest_page_two = SectorPageFactory(slug='foo', parent=invest_page_one)
    invest_page_three = SectorPageFactory(slug='bar', parent=invest_page_two)

    assert invest_page_two.full_path == '/industries/foo/'
    assert invest_page_three.full_path == '/industries/foo/bar/'

    fas_app = FindASupplierAppFactory(parent=root_page)
    fas_industry_landing_page = IndustryLandingPageFactory(parent=fas_app)
    fas_industry_one = IndustryPageFactory(
        slug='foo', parent=fas_industry_landing_page)
    fas_industry_two = IndustryPageFactory(
        slug='bar', parent=fas_industry_landing_page)
    fas_industry_article = IndustryArticlePageFactory(
        slug='article', parent=fas_industry_two)

    assert fas_industry_one.full_path == '/industries/foo/'
    assert fas_industry_two.full_path == '/industries/bar/'
    assert fas_industry_article.full_path == '/industry-articles/article/'

    domestic_homepage = HomePageFactory(parent=root_page)
    domestic_page_one = TopicLandingPageFactory(
        parent=domestic_homepage, slug='topic')
    domestic_page_two = ArticleListingPageFactory(
        parent=domestic_page_one, slug='list')
    domestic_page_three = ArticlePageFactory(
        parent=domestic_page_two, slug='article')

    assert domestic_page_two.full_path == '/topic/list/'
    assert domestic_page_three.full_path == '/topic/list/article/'

    domestice_site_policy = SitePolicyPagesFactory(parent=domestic_homepage)
    domestic_cookies_one = PrivacyAndCookiesPageFactory(
        slug='privacy', parent=domestice_site_policy)
    domestic_cookies_two = PrivacyAndCookiesPageFactory(
        slug='cookies', parent=domestic_cookies_one)

    assert domestic_cookies_one.full_path == '/privacy/'
    assert domestic_cookies_two.full_path == '/privacy/cookies/'

    international_homepage = InternationalHomePageFactory(parent=root_page)
    international_page_one = InternationalTopicLandingPageFactory(
        parent=international_homepage, slug='topic')
    international_page_two = InternationalArticleListingPageFactory(
        parent=international_page_one, slug='list')
    international_page_three = InternationalArticlePageFactory(
        parent=international_page_two, slug='article')

    assert international_page_two.full_path == '/topic/list/'
    assert international_page_three.full_path == '/topic/list/article/'
def test_home_page_related_pages(root_page, rf):
    related_page_one = InternationalArticlePageFactory(parent=root_page,
                                                       slug='one')
    related_page_two = InternationalCampaignPageFactory(parent=root_page,
                                                        slug='two')

    home_page = InternationalHomePageFactory(
        parent=root_page,
        slug='home-page',
        related_page_one=related_page_one,
        related_page_two=related_page_two,
    )

    serializer = InternationalHomePageSerializer(
        instance=home_page, context={'request': rf.get('/')})

    assert len(serializer.data['related_pages']) == 2
    for page in serializer.data['related_pages']:
        assert 'title' in page
        assert 'teaser' in page
        assert 'thumbnail' in page