<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8

import pytest
import requests


@pytest.mark.parametrize('path', [
    # Check pagination is working correctly
    '/page/2/', '/page/3/',
])
def test_pages_appear_correctly(hostname, path):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200


@pytest.mark.parametrize('path, text_in_page', [
    ('2017/', 'Posts from 2017'),
    ('2017/07/', 'Posts from July 2017'),
    ('', 'Older posts'),
    ('', '<title>alexwlchan</title>'),
    ('archive/', '<h3>2017</h3>'),

    # Smartypants is working
    ('2017/09/lazy-reading-in-python', u'kept in Amazon S3 &ndash; XML exports'),
    ('2017/09/ode-to-docopt', u'I&rsquo;ve used it in multiple languages'),

    # Syntax highlighting is being applied correctly
    ('2017/09/useful-git-commands/', '''<code class="language-console" data-lang="console"><span></span><span class="gp">$</span> git rev-parse --show-toplevel
<span class="go">/Users/alexwlchan/repos/alexwlchan.net</span>
</code>'''),

    # We're not adding trailing commas to tags
    ('2017/09/ode-to-docopt', 'python</a>, <a'),

    # I don't really want to minify it twice (and minification might vary
    # in subtle ways), but I can look for blocks which aren't minified in
    # the template and *should* be minified in the output.
    ('feeds/all.atom.xml', '<author><name><NAME></name>'),
    ('feeds/all.atom.xml', '</entry><entry>'),

    # Footnotes are rendered correctly
    ('2017/01/scrape-logged-in-ao3', '<a href="#fn1" rel="footnote">1</a>'),

    # Tweets are being rendered correctly
    ('2014/07/overcast/', '<div class="tweet"><blockquote>'),
    ('2014/07/overcast/', '</blockquote></div>'),
    ('2014/07/overcast/',
     '<a href="https://twitter.com/alexwlchan">@alexwlchan</a>'),
    ('2014/07/overcast', 'so:<br /><br />Episode 1: A<br />'),
    ('2017/10/lightning-talks/',
     '<a href="https://twitter.com/hashtag/PyConUK">#PyConUK</a>'),
    ('2017/10/lightning-talks/', '<div class="media">'),
    ('2017/04/lessons-from-alterconf/', '<div class="media">'),
])
def test_text_appears_in_pages(hostname, path, text_in_page):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200
    assert text_in_page in resp.text


@pytest.mark.parametrize('path, text', [
    # Year markers only appear in the global archives, not year or month pages
    ('2017/', '<h3>2017</h3>'),
    ('2017/07/', '<h3>2017</h3>'),
])
def test_text_does_not_appear_in_pages(hostname, path, text):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200
    assert text not in resp.text<commit_msg>Add a test that looks for a stray '<' in RSS<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8

import pytest
import requests


@pytest.mark.parametrize('path', [
    # Check pagination is working correctly
    '/page/2/', '/page/3/',
])
def test_pages_appear_correctly(hostname, path):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200


@pytest.mark.parametrize('path, text_in_page', [
    ('2017/', 'Posts from 2017'),
    ('2017/07/', 'Posts from July 2017'),
    ('', 'Older posts'),
    ('', '<title>alexwlchan</title>'),
    ('archive/', '<h3>2017</h3>'),

    # Smartypants is working
    ('2017/09/lazy-reading-in-python', u'kept in Amazon S3 &ndash; XML exports'),
    ('2017/09/ode-to-docopt', u'I&rsquo;ve used it in multiple languages'),

    # Syntax highlighting is being applied correctly
    ('2017/09/useful-git-commands/', '''<code class="language-console" data-lang="console"><span></span><span class="gp">$</span> git rev-parse --show-toplevel
<span class="go">/Users/alexwlchan/repos/alexwlchan.net</span>
</code>'''),

    # We're not adding trailing commas to tags
    ('2017/09/ode-to-docopt', 'python</a>, <a'),

    # I don't really want to minify it twice (and minification might vary
    # in subtle ways), but I can look for blocks which aren't minified in
    # the template and *should* be minified in the output.
    ('feeds/all.atom.xml', '<author><name><NAME></name>'),
    ('feeds/all.atom.xml', '</entry><entry>'),

    # Footnotes are rendered correctly
    ('2017/01/scrape-logged-in-ao3', '<a href="#fn1" rel="footnote">1</a>'),

    # Tweets are being rendered correctly
    ('2014/07/overcast/', '<div class="tweet"><blockquote>'),
    ('2014/07/overcast/', '</blockquote></div>'),
    ('2014/07/overcast/',
     '<a href="https://twitter.com/alexwlchan">@alexwlchan</a>'),
    ('2014/07/overcast', 'so:<br /><br />Episode 1: A<br />'),
    ('2017/10/lightning-talks/',
     '<a href="https://twitter.com/hashtag/PyConUK">#PyConUK</a>'),
    ('2017/10/lightning-talks/', '<div class="media">'),
    ('2017/04/lessons-from-alterconf/', '<div class="media">'),
])
def test_text_appears_in_pages(hostname, path, text_in_page):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200
    assert text_in_page in resp.text


@pytest.mark.parametrize('path, text', [
    # Year markers only appear in the global archives, not year or month pages
    ('2017/', '<h3>2017</h3>'),
    ('2017/07/', '<h3>2017</h3>'),

    # There's isn't a stray '&lt;' in the RSS feed
    ('feeds/all.atom.xml', '&lt;</content>'),
])
def test_text_does_not_appear_in_pages(hostname, path, text):
    resp = requests.get('http://%s/%s' % (hostname, path))
    assert resp.status_code == 200
    assert text not in resp.text
{'fraction_non_alphanumeric': 0.20206409560021726, 'fraction_numerical': 0.04888647474198805, 'mean_word_length': 3.795138888888889, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 80, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876791', 'n_tokens_mistral': 2162, 'n_tokens_neox': 1940, 'n_words': 441}