def test_search_security_error():
    """Test that the DefusedXmlException is handled as a security error."""

    err = ErrorBundle()
    url = 'tests/resources/searchprovider/lol.xml'
    detect_opensearch(err, url, listed=False)

    assert err.failed(), 'Expected failure'
    assert err.errors[0]['id'] == ('opensearch', 'security_error')
Ejemplo n.º 2
0
def test_search_security_error():
    """Test that the DefusedXmlException is handled as a security error."""

    err = ErrorBundle()
    url = "tests/resources/searchprovider/lol.xml"
    detect_opensearch(err, url, listed=False)

    assert err.failed(), "Expected failure"
    assert err.errors[0]['id'] == ('opensearch', 'security_error')
Ejemplo n.º 3
0
def test_search(err, package, expectation=0):
    "Tests the package to see if it is a search provider."

    expected_search_provider = expectation in (PACKAGE_ANY, PACKAGE_SEARCHPROV)

    # If we're not expecting a search provider, warn the user and stop
    # testing it like a search provider.
    if not expected_search_provider:
        return err.warning(("main", "test_search", "extension"), "Unexpected file extension.")

    # Is this a search provider?
    detect_opensearch(err, package, listed=err.get_resource("listed"))

    if expected_search_provider and not err.failed():
        err.detected_type = PACKAGE_SEARCHPROV
Ejemplo n.º 4
0
def test_search(err, package, expectation=0):
    "Tests the package to see if it is a search provider."

    expected_search_provider = expectation in (PACKAGE_ANY, PACKAGE_SEARCHPROV)

    # If we're not expecting a search provider, warn the user and stop
    # testing it like a search provider.
    if not expected_search_provider:
        return err.warning(("main", "test_search", "extension"),
                           "Unexpected file extension.")

    # Is this a search provider?
    detect_opensearch(err, package, listed=err.get_resource("listed"))

    if expected_search_provider and not err.failed():
        err.detected_type = PACKAGE_SEARCHPROV
Ejemplo n.º 5
0
def test_search(err, package, expectation=0):
    'Tests the package to see if it is a search provider.'

    expected_search_provider = expectation in (PACKAGE_ANY, PACKAGE_SEARCHPROV)

    # If we're not expecting a search provider, warn the user and stop
    # testing it like a search provider.
    if not expected_search_provider:
        return err.warning(('main', 'test_search', 'extension'),
                           'Unexpected file extension.')

    # Is this a search provider?
    detect_opensearch(err, package, listed=err.get_resource('listed'))

    if expected_search_provider and not err.failed():
        err.detected_type = PACKAGE_SEARCHPROV
Ejemplo n.º 6
0
def test_search(err, package, expectation=0):
    'Tests the package to see if it is a search provider.'

    expected_search_provider = expectation in (PACKAGE_ANY,
                                               PACKAGE_SEARCHPROV)

    # If we're not expecting a search provider, warn the user and stop
    # testing it like a search provider.
    if not expected_search_provider:
        return err.warning(('main',
                            'test_search',
                            'extension'),
                           'Unexpected file extension.')

    # Is this a search provider?
    detect_opensearch(err, package, listed=err.get_resource('listed'))

    if expected_search_provider and not err.failed():
        err.detected_type = PACKAGE_SEARCHPROV
Ejemplo n.º 7
0
def _do_test(url, failure=True, listed=False):
    err = ErrorBundle()
    results = detect_opensearch(err, open(url), listed=listed)

    if results.failed():
        print results.print_summary()

    if failure:
        assert err.failed(), 'Expected failure'
    else:
        assert not err.failed(), 'Expected pass'
Ejemplo n.º 8
0
def _do_test(url, failure=True, listed=False):
    err = ErrorBundle()
    results = detect_opensearch(err, open(url), listed=listed)

    if results.failed():
        print results.print_summary()

    if failure:
        assert err.failed()
    else:
        assert not err.failed()
Ejemplo n.º 9
0
def test_nonparsing_xml():
    """Tests that a failure is generated for bad XML on OpenSearch"""

    err = ErrorBundle()
    detect_opensearch(err, "tests/resources/searchprovider/bad_xml.xml")
    assert err.failed()
Ejemplo n.º 10
0
def test_treat_unicode_paths_as_files():
    """Test that unicode filepaths are treated as filepaths"""

    err = ErrorBundle()
    detect_opensearch(err, u"tests/resources/searchprovider/pass.xml")
    assert not err.failed()
Ejemplo n.º 11
0
def test_nonparsing_xml():
    """Tests that a failure is generated for bad XML on OpenSearch"""

    err = ErrorBundle()
    detect_opensearch(err, "foo/bar/_asdf")
    assert err.failed()
def test_nonparsing_xml():
    """Tests that a failure is generated for bad XML on OpenSearch"""

    err = ErrorBundle()
    detect_opensearch(err, 'tests/resources/searchprovider/bad_xml.xml')
    assert err.failed()
def test_treat_unicode_paths_as_files():
    """Test that unicode filepaths are treated as filepaths"""

    err = ErrorBundle()
    detect_opensearch(err, u'tests/resources/searchprovider/pass.xml')
    assert not err.failed()