コード例 #1
0
def test_no_wellformed():
    """Test scraper without well-formed check."""
    scraper = OfficeScraper("tests/data/application_msword/valid_11.0.doc",
                            False)
    scraper.scrape_file()
    assert partial_message_included("Skipping scraper", scraper.messages())
    assert scraper.well_formed is None
コード例 #2
0
def test_scraper_valid_file(filename, mimetype, evaluate_scraper):
    """
    Test valid files with scraper.

    :filename: Test file name
    :mimetype: File MIME type
    """
    correct = parse_results(filename, mimetype, {}, True)
    scraper = OfficeScraper(filename=correct.filename, mimetype=mimetype)
    scraper.scrape_file()
    correct.update_mimetype(UNAV)
    correct.update_version(UNAV)

    evaluate_scraper(scraper, correct, False)
    assert scraper.messages()
    assert not scraper.errors()
コード例 #3
0
def test_scraper_valid_file(filename, mimetype, evaluate_scraper):
    """Test valid files with scraper."""
    result_dict = {
        "purpose": "Test valid file.",
        "stdout_part": "",
        "stderr_part": ""
    }
    correct = parse_results(filename, mimetype, result_dict, True)
    scraper = OfficeScraper(correct.filename, True, correct.params)
    scraper.scrape_file()
    correct.streams[0]["version"] = "(:unav)"
    correct.streams[0]["mimetype"] = "(:unav)"

    evaluate_scraper(scraper, correct, False)
    assert scraper.messages()
    assert not scraper.errors()
コード例 #4
0
def test_scraper_correct_application(filename, mimetype, application):
    """
    Test that the correct LibreOffice application is selected.

    If all necessary LibreOffice components are not installed, some files may
    be scraped with a different application than intended (e.g. using Impress
    for ODG files), and this may work, but it should not be relied on. This
    test makes sure that all components are present and they are used for the
    correct files.

    :filename: Test file name
    :mimetype: File MIME type
    :application: Correct office application
    """
    testfile = os.path.join("tests/data", mimetype.replace("/", "_"), filename)

    scraper = OfficeScraper(filename=testfile, mimetype=mimetype)
    scraper.scrape_file()

    assert partial_message_included("using filter : {}".format(application),
                                    scraper.messages())