def test_region_aware_cache_populator_async():
    page = InternationalArticleListingPageFactory()

    cache.RegionAwareCachePopulator.populate_async(page)
    for language_code in page.translated_languages:
        for region in cache.RegionAwareCachePopulator.regions:
            assert cache.PageCache.get(
                page_id=page.id,
                lang=language_code,
                region=region,
            )
Example #2
0
def test_region_aware_cache_populator():
    page = InternationalArticleListingPageFactory()

    cache.RegionAwareCachePopulator.populate(page.pk)
    for language_code in page.translated_languages:
        for region in cache.RegionAwareCachePopulator.regions:
            assert cache.PageCache.get(slug=page.slug,
                                       params={
                                           'service_name': page.service_name,
                                           'lang': language_code,
                                           'region': region,
                                       })
Example #3
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/'