Esempio n. 1
0
def test_scraper_pdf(filename, result_dict, evaluate_scraper):
    """
    Test Ghostscript scraper.

    :filename: Test filename. Character X is replaced with versions 1.7,
               A-1a, A-2b, and A-3b. All of these files must be found.
    :result_dict: Result dict containing the test purpose, and parts of
                  expected results of stdout and stderr
    """
    for ver in ["1.7", "A-1a", "A-2b", "A-3b"]:
        filename = filename.replace("X", ver)
        correct = parse_results(filename, "application/pdf", result_dict, True)
        scraper = GhostscriptScraper(filename=correct.filename,
                                     mimetype="application/pdf")
        scraper.scrape_file()

        # Ghostscript cannot handle version or MIME type
        correct.streams[0]["version"] = UNAV
        correct.streams[0]["mimetype"] = UNAV

        evaluate_scraper(scraper, correct, eval_output=False)

        if scraper.well_formed:
            assert not partial_message_included("Error", scraper.messages())
            assert not scraper.errors()
        else:
            assert partial_message_included(correct.stderr_part,
                                            scraper.errors())
            assert partial_message_included(correct.stdout_part,
                                            scraper.messages())
Esempio n. 2
0
def test_no_wellformed():
    """Test scraper without well-formed check."""
    scraper = GhostscriptScraper("tests/data/application_pdf/valid_1.4.pdf",
                                 False)
    scraper.scrape_file()
    assert partial_message_included("Skipping scraper", scraper.messages())
    assert scraper.well_formed is None
Esempio n. 3
0
def test_scraper_pdf(filename, result_dict, evaluate_scraper):
    """Test scraper."""
    for ver in ["1.7", "A-1a", "A-2b", "A-3b"]:
        filename = filename.replace("X", ver)
        correct = parse_results(filename, "application/pdf", result_dict, True)
        scraper = GhostscriptScraper(correct.filename, True, correct.params)
        scraper.scrape_file()

        # Ghostscript cannot handle version or MIME type
        correct.version = "(:unav)"
        correct.streams[0]["version"] = "(:unav)"
        correct.mimetype = "(:unav)"
        correct.streams[0]["mimetype"] = "(:unav)"

        evaluate_scraper(scraper, correct, eval_output=False)

        if scraper.well_formed:
            assert not partial_message_included("Error", scraper.messages())
            assert not scraper.errors()
        else:
            assert partial_message_included(correct.stderr_part,
                                            scraper.errors())
            assert partial_message_included(correct.stdout_part,
                                            scraper.messages())