<commit_before>from django.template.loader import render_to_string

from core import forms


def test_social_share_all_populated():
    context = {
        'social': {
            'image': 'image.png',
            'title': 'a title',
            'description': 'a description',
        }
    }
    html = render_to_string('social.html', context)

    assert '<meta property="og:type" content="website" />' in html
    assert '<meta property="og:image" content="image.png" />' in html
    assert '<meta property="og:title" content="a title" />'in html
    assert '<meta property="og:description" content="a description" />' in html


def test_social_share_not_populated():
    context = {}
    html = render_to_string('social.html', context)
    url = '/static/govuk-0.18.0/assets/images/opengraph-image.f86f1d0dd106.png'

    assert '<meta property="og:type" content="website" />' in html
    assert '<meta property="og:image" content="{0}" />'.format(url) in html
    assert '<meta property="og:title"' not in html
    assert '<meta property="og:description"' not in html


def test_robots(rf):
    request = rf.get('/')

    context = {
        'request': request,
    }

    html = render_to_string('robots.txt', context)

    assert 'Sitemap: http://testserver/sitemap.xml' in html


def test_utm_cookie_domain():
    context = {
        'analytics': {
            'UTM_COOKIE_DOMAIN': '.thing.com',
        }
    }
    html = render_to_string('enrolment-base.html', context)

    assert '<meta id="utmCookieDomain" value=".thing.com" />' in html

<commit_msg>Fix UTM Cookie test.<commit_after>from django.template.loader import render_to_string

from core import forms


def test_social_share_all_populated():
    context = {
        'social': {
            'image': 'image.png',
            'title': 'a title',
            'description': 'a description',
        }
    }
    html = render_to_string('social.html', context)

    assert '<meta property="og:type" content="website" />' in html
    assert '<meta property="og:image" content="image.png" />' in html
    assert '<meta property="og:title" content="a title" />'in html
    assert '<meta property="og:description" content="a description" />' in html


def test_social_share_not_populated():
    context = {}
    html = render_to_string('social.html', context)
    url = '/static/govuk-0.18.0/assets/images/opengraph-image.f86f1d0dd106.png'

    assert '<meta property="og:type" content="website" />' in html
    assert '<meta property="og:image" content="{0}" />'.format(url) in html
    assert '<meta property="og:title"' not in html
    assert '<meta property="og:description"' not in html


def test_robots(rf):
    request = rf.get('/')

    context = {
        'request': request,
    }

    html = render_to_string('robots.txt', context)

    assert 'Sitemap: http://testserver/sitemap.xml' in html


def test_utm_cookie_domain():
    context = {
        'directory_components_analytics': {
            'UTM_COOKIE_DOMAIN': '.thing.com',
        }
    }
    html = render_to_string('enrolment-base.html', context)

    assert '<meta id="utmCookieDomain" value=".thing.com" />' in html


{'fraction_non_alphanumeric': 0.14797211660329532, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 3.2149532710280373, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1987452', 'n_tokens_mistral': 1024, 'n_tokens_neox': 985, 'n_words': 227}