Exemplo n.º 1
0
def test_htmlcheck_on_invalid_html():
    try:
        with runfilter("tidycheck", invalid_html, ext=".html"):
            assert False, "should not get here"
    except UserFeedback as e:
        assert "missing <!DOCTYPE>" in str(e)
        assert "inserting missing 'title'" in str(e)
Exemplo n.º 2
0
def test_add_new_document():
    with runfilter("newdoc", "hello") as doc:
        assert doc.children[-1].key == "subdir/newfile.txt|processtext"
        assert str(doc.output_data()) == "we added a new file"

        assert "doc:subdir/example.txt|newdoc" in doc.wrapper.nodes
        assert "doc:subdir/newfile.txt|processtext" in doc.wrapper.nodes
Exemplo n.º 3
0
def test_add_new_document():
    with runfilter("newdoc", "hello") as doc:
        assert doc.children[-1].key == "subdir/newfile.txt|processtext"
        assert str(doc.output_data()) == "we added a new file"

        assert "doc:subdir/example.txt|newdoc" in doc.wrapper.nodes
        assert "doc:subdir/newfile.txt|processtext" in doc.wrapper.nodes
Exemplo n.º 4
0
def test_no_blank_anonymous_first_section():
    with runfilter('soups',
                   "<h1>first</h1><p>foo</p><h1>second</h1>",
                   ext=".html") as doc:
        assert doc.output_data().keys() == [
            u'first', u'second', u'Actual Document Contents'
        ]
Exemplo n.º 5
0
def test_nested_html():
    with runfilter('soups', nested_html) as doc:
        data = doc.output_data()
        assert unicode(data) == expected
        assert data.keys() == [
            u'First', u'Second', u'Actual Document Contents'
        ]
Exemplo n.º 6
0
def test_htmlcheck_on_invalid_html():
    try:
        with runfilter("tidycheck", invalid_html, ext=".html"):
            assert False, "should not get here"
    except UserFeedback as e:
        assert "missing <!DOCTYPE>" in str(e)
        assert "inserting missing 'title'" in str(e)
Exemplo n.º 7
0
def test_xxml():
    with runfilter("xxml", XML) as doc:
        assert doc.output_data(
        )['foo:source'] == '<element id="foo">foo</element>'
        assert doc.output_data()['foo:text'] == 'foo'
        assert '<div class="highlight">' in doc.output_data(
        )['foo:html-source']
Exemplo n.º 8
0
def test_markdown_output():
    with runfilter('markdown|soups', md) as doc:
        data = doc.output_data()

        assert data.keys() == [u'foo', u'bar', u'barbaz', u'Actual Document Contents']

        assert data['foo']['level'] == 1
        assert data['bar']['level'] == 1
        assert data['barbaz']['level'] == 2

        assert data['foo']['id'] == 'foo'
        assert data['bar']['id'] == 'bar'
        assert data['barbaz']['id'] == 'barbaz'
Exemplo n.º 9
0
def test_markdown_output():
    with runfilter('markdown|soups', md) as doc:
        data = doc.output_data()

        assert list(data.keys()) == ['foo', 'bar', 'barbaz', 'Actual Document Contents']

        assert data['foo']['level'] == 1
        assert data['bar']['level'] == 1
        assert data['barbaz']['level'] == 2

        assert data['foo']['id'] == 'foo'
        assert data['bar']['id'] == 'bar'
        assert data['barbaz']['id'] == 'barbaz'
Exemplo n.º 10
0
def test_soup_sections_filter():
    with runfilter('soups', html, ext='.html') as doc:
        data = doc.output_data()

        assert data.keys() == [u'The First Named Section',
                u'Nested In First Section', u'The 2nd Section',
                u'Actual Document Contents']

        first_section = data["The First Named Section"]
        assert first_section['contents'] == None
        assert first_section['level'] == 1

        nested_section = data["Nested In First Section"]
        assert nested_section['level'] == 2
        assert first_section['contents'] == None

        final_section = data["The 2nd Section"]
        assert final_section['level'] == 1
        assert final_section['contents'] == None

        contents_section = data['Actual Document Contents']
        assert contents_section['level'] == 1
Exemplo n.º 11
0
def test_soup_sections_filter():
    with runfilter('soups', html, ext='.html') as doc:
        data = doc.output_data()

        assert list(data.keys()) == ['The First Named Section',
                'Nested In First Section', 'The 2nd Section',
                'Actual Document Contents']

        first_section = data["The First Named Section"]
        assert first_section['contents'] == None
        assert first_section['level'] == 1

        nested_section = data["Nested In First Section"]
        assert nested_section['level'] == 2
        assert first_section['contents'] == None

        final_section = data["The 2nd Section"]
        assert final_section['level'] == 1
        assert final_section['contents'] == None

        contents_section = data['Actual Document Contents']
        assert contents_section['level'] == 1
Exemplo n.º 12
0
def test_inactive_filters_skip():
    with runfilter("inactive", "hello"):
        pass
Exemplo n.º 13
0
def test_xxml():
    with runfilter("xxml", XML) as doc:
        assert doc.output_data()['foo:source'] == '<element id="foo">foo</element>'
        assert doc.output_data()['foo:text'] == 'foo'
        assert '<div class="highlight">' in doc.output_data()['foo:html-source']
Exemplo n.º 14
0
def test_tidyerrors():
    with runfilter("tidyerrors", invalid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert "missing <!DOCTYPE>" in output
        assert "inserting missing 'title'" in output
Exemplo n.º 15
0
def test_nested_html():
    with runfilter('soups', nested_html) as doc:
        data = doc.output_data()
        assert str(data) == expected
        assert list(data.keys()) == ['First', 'Second', 'Actual Document Contents']
Exemplo n.º 16
0
def test_latex():
    with runfilter('latex', LATEX) as doc:
        assert ".pdf" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 17
0
def test_latex_dvi():
    with runfilter('latexdvi', LATEX) as doc:
        assert ".dvi" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 18
0
def test_run_git():
    with runfilter("git", PATH_TO_LOCAL_REPO) as doc:
        doc.output_data()
Exemplo n.º 19
0
def test_htmltidy():
    with runfilter("htmltidy", min_valid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert "<body>" in output
Exemplo n.º 20
0
def test_no_blank_anonymous_first_section():
    with runfilter('soups', "<h1>first</h1><p>foo</p><h1>second</h1>", ext=".html") as doc:
        assert doc.output_data().keys() == [u'first', u'second', u'Actual Document Contents']
Exemplo n.º 21
0
def test_nested_html():
    with runfilter('soups', nested_html) as doc:
        data = doc.output_data()
        assert unicode(data) == expected
        assert data.keys() == [u'First', u'Second', u'Actual Document Contents']
Exemplo n.º 22
0
def test_tikz():
    with runfilter('tikz', TIKZ) as doc:
        assert ".pdf" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 23
0
def test_run_gitrepo():
    with runfilter("repo", REMOTE_REPO_HTTPS) as doc:
        assert len(doc.wrapper.nodes) > 20
Exemplo n.º 24
0
def test_htmltidy():
    with runfilter("htmltidy", min_valid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert "<body>" in output
Exemplo n.º 25
0
def test_git_commit():
    with runfilter("gitcommit", REMOTE_REPO_HTTPS) as doc:
        output = doc.output_data()
        patches = json.loads(output['patches'])
        assert output['author-name'] == "Ana Nelson"
        assert output['author-email'] == "*****@*****.**"
Exemplo n.º 26
0
def test_phantomjs_render_filter():
    with runfilter("phrender", "<p>hello</p>") as doc:
        assert doc.output_data().is_cached()
Exemplo n.º 27
0
def test_run_git_remote():
    with runfilter("git", REMOTE_REPO_HTTPS) as doc:
        doc.output_data()
Exemplo n.º 28
0
def test_tikz():
    with runfilter('tikz', TIKZ) as doc:
        assert ".pdf" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 29
0
def test_tikz():
    # TODO fix for tikz not installed
    raise SkipTest()
    with runfilter('tikz', TIKZ) as doc:
        assert ".pdf" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 30
0
def test_latex():
    with runfilter('latex', LATEX) as doc:
        assert ".pdf" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 31
0
def test_tidyerrors():
    with runfilter("tidyerrors", invalid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert "missing <!DOCTYPE>" in output
        assert "inserting missing 'title'" in output
Exemplo n.º 32
0
def test_htmlcheck_on_valid_html():
    with runfilter("tidycheck", min_valid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert output == min_valid_html
Exemplo n.º 33
0
def test_htmlcheck_on_valid_html():
    with runfilter("tidycheck", min_valid_html, ext=".html") as doc:
        output = str(doc.output_data())
        assert output == min_valid_html
Exemplo n.º 34
0
def test_inactive_filters_skip():
    with runfilter("inactive", "hello"):
        pass
Exemplo n.º 35
0
def test_latex_dvi():
    with runfilter('latexdvi', LATEX) as doc:
        assert ".dvi" in doc.output_data().name
        assert doc.output_data().is_cached()
Exemplo n.º 36
0
def test_phantomjs_render_filter():
    with runfilter("phrender", "<p>hello</p>") as doc:
        assert doc.output_data().is_cached()