Exemplo n.º 1
0
def test_response_too_big_and_link_in_header(tmpdir, caplog):
    _setup_http_mocks(pingback=('header',), webmention=(), fat_html=True)
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 1
    assert 'The response for URL http://localhost/sub/some-page.html was too large, and hence was truncated' in caplog.text
Exemplo n.º 2
0
def test_pingback_already_registered(tmpdir, caplog):
    _setup_http_mocks(pingback=('header', 'already_registered'), webmention=())
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Pingback already registered for URL http://localhost/sub/some-page.html, XML-RPC response: code=48 - The pingback has already been registered.' in caplog.text
Exemplo n.º 3
0
def test_webmention_http_error(tmpdir, caplog):
    _setup_http_mocks(pingback=(), webmention=('header', 'http_error'))
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Failed to send WebMention for link url http://localhost/sub/some-page.html' in caplog.text
    assert '503' in caplog.text
Exemplo n.º 4
0
def test_webmention_ok_without_http_header(tmpdir):
    _setup_http_mocks(pingback=(), webmention=('link',))
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 1
Exemplo n.º 5
0
def test_pingback_xmlrpc_error(tmpdir, caplog):
    _setup_http_mocks(pingback=('header', 'xmlrpc_error'), webmention=())
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Pingback XML-RPC request failed for URL http://localhost/sub/some-page.html: code=0 - Unexpected error.' in caplog.text
Exemplo n.º 6
0
def test_link_host_not_reachable(tmpdir, caplog):
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Failed to retrieve web page for link url http://localhost/sub/some-page.html' in caplog.text
    assert 'Failed to retrieve web page for link url http://localhost/sub/some-page.html' in caplog.text
    assert 'ConnectionError' in caplog.text
Exemplo n.º 7
0
def test_ignore_internal_links(tmpdir, caplog):
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir, site_url='http://localhost/sub/')
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Link url http://localhost/sub/some-page.html skipped because is starts with http://localhost/sub/' in caplog.text
Exemplo n.º 8
0
def test_cache(tmpdir, caplog):
    _setup_http_mocks()
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 2
    assert process_all_articles_linkbacks([article_generator]) == 0
    assert 'Link url http://localhost/sub/some-page.html skipped because it has already been processed (present in cache)' in caplog.text
Exemplo n.º 9
0
def test_ok_zero_linkbacks(tmpdir):
    _setup_http_mocks(pingback=(), webmention=())
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 0
Exemplo n.º 10
0
def test_ok(tmpdir):
    _setup_http_mocks()
    article_generator = _build_article_generator(TEST_CONTENT_DIR, tmpdir)
    assert process_all_articles_linkbacks([article_generator]) == 2