示例#1
0
def test_proper_linked_manifest_relative():
    """
    Test that linked manifests are imported relatively when using relative
    paths.
    """

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest':
        'tests/resources/submain/linkman/subdir.manifest',
        'dir/level2.manifest':
        'tests/resources/submain/linkman/foosub.manifest',
        'dir/foo.manifest':
        'tests/resources/submain/linkman/base2.manifest'
    })

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed() or err.notices

    # From the linked manifest:
    zaps = list(chrome.get_triples(subject='zap'))
    assert zaps
    assert zaps[0]['filename'] == 'dir/foo.manifest'
    assert zaps[0]['context'].data == ['zap baz', '']
示例#2
0
def test_proper_linked_manifest_relative():
    """
    Test that linked manifests are imported relatively when using relative
    paths.
    """

    err = ErrorBundle()
    package = MockXPI(
        {
            "chrome.manifest": "tests/resources/submain/linkman/subdir.manifest",
            "dir/level2.manifest": "tests/resources/submain/linkman/foosub.manifest",
            "dir/foo.manifest": "tests/resources/submain/linkman/base2.manifest",
        }
    )

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the linked manifest:
    zaps = list(chrome.get_entries("zap"))
    assert zaps
    eq_(zaps[0]["filename"], "dir/foo.manifest")
    eq_(zaps[0]["context"].data, ["zap baz", ""])
示例#3
0
def _do_test(path,
             test,
             failure=True,
             require_install=False,
             set_type=0,
             listed=False,
             xpi_mode='r'):

    package_data = open(path, 'rb')
    package = XPIManager(package_data, mode=xpi_mode, name=path)
    err = ErrorBundle()
    if listed:
        err.save_resource('listed', True)

    # Populate in the dependencies.
    if set_type:
        err.detected_type = set_type  # Conduit test requires type
    if require_install:
        err.save_resource('has_install_rdf', True)
        rdf_data = package.read('install.rdf')
        install_rdf = RDFParser(err, rdf_data)
        err.save_resource('install_rdf', install_rdf)

    populate_chrome_manifest(err, package)

    test(err, package)

    print err.print_summary(verbose=True)

    if failure:
        assert err.failed()
    else:
        assert not err.failed()

    return err
示例#4
0
def _do_test(path, test, failure=True,
             require_install=False, set_type=0,
             listed=False, xpi_mode="r"):

    package_data = open(path, "rb")
    package = XPIManager(package_data, mode=xpi_mode, name=path)
    err = ErrorBundle()
    if listed:
        err.save_resource("listed", True)

    # Populate in the dependencies.
    if set_type:
        err.detected_type = set_type # Conduit test requires type
    if require_install:
        err.save_resource("has_install_rdf", True)
        rdf_data = package.read("install.rdf")
        install_rdf = RDFParser(err, rdf_data)
        err.save_resource("install_rdf", install_rdf)

    populate_chrome_manifest(err, package)

    test(err, package)

    print err.print_summary(verbose=True)

    if failure:
        assert err.failed()
    else:
        assert not err.failed()

    return err
示例#5
0
def test_missing_manifest_link():
    """Test that missing linked manifests are properly flagged."""

    err = ErrorBundle()
    package = MockXPI({"chrome.manifest": "tests/resources/submain/linkman/base1.manifest"})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed()
    assert err.notices

    # From the base file:
    assert list(chrome.get_entries("foo"))
    # From the linked manifest:
    assert not list(chrome.get_entries("zap"))
示例#6
0
def test_missing_manifest_link():
    """Test that missing linked manifests are properly flagged."""

    err = ErrorBundle()
    package = MockXPI(
        {'chrome.manifest': 'tests/resources/submain/linkman/base1.manifest'})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed()
    assert err.notices

    # From the base file:
    assert list(chrome.get_triples(subject='foo'))
    # From the linked manifest:
    assert not list(chrome.get_triples(subject='zap'))
def test_missing_manifest_link():
    """Test that missing linked manifests are properly flagged."""

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest': 'tests/resources/submain/linkman/base1.manifest'})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed()
    assert err.notices

    # From the base file:
    assert list(chrome.get_triples(subject='foo'))
    # From the linked manifest:
    assert not list(chrome.get_triples(subject='zap'))
示例#8
0
def test_proper_linked_manifest():
    """Test that linked manifests are imported properly."""

    err = ErrorBundle()
    package = MockXPI({
        "chrome.manifest": "tests/resources/submain/linkman/base1.manifest",
        "submanifest.manifest":
            "tests/resources/submain/linkman/base2.manifest"})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the base file:
    assert list(chrome.get_triples(subject="foo"))
    # From the linked manifest:
    assert list(chrome.get_triples(subject="zap"))
示例#9
0
def test_populate_chrome_manifest():
    """Ensure that the chrome manifest is populated if available."""

    err = MockErrorHandler(None)
    package_contents = {"chrome.manifest":
            "tests/resources/chromemanifest/chrome.manifest"}
    package = MockXPI(package_contents)

    submain.populate_chrome_manifest(err, MockXPI())
    assert not err.pushable_resources

    submain.populate_chrome_manifest(err, package)
    assert err.pushable_resources
    assert err.pushable_resources["chrome.manifest"]
    print err.pushable_resources
    assert isinstance(err.pushable_resources["chrome.manifest"],
                      ChromeManifest)

    assert not err.resources
def test_linked_manifest_recursion():
    """Test that recursive linked manifests are flagged properly."""

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest': 'tests/resources/submain/linkman/base1.manifest',
        'submanifest.manifest':
            'tests/resources/submain/linkman/recurse.manifest'})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    print err.print_summary(verbose=True)

    assert err.failed()
    assert not err.notices

    # From the base file:
    assert list(chrome.get_triples(subject='foo'))
    # From the linked manifest:
    assert not list(chrome.get_triples(subject='zap'))
def test_proper_linked_manifest():
    """Test that linked manifests are imported properly."""

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest': 'tests/resources/submain/linkman/base1.manifest',
        'submanifest.manifest':
            'tests/resources/submain/linkman/base2.manifest'})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed() or err.notices

    # From the base file:
    assert list(chrome.get_triples(subject='foo'))
    # From the linked manifest:
    zaps = list(chrome.get_triples(subject='zap'))
    assert zaps
    assert zaps[0]['filename'] == 'submanifest.manifest'
    assert zaps[0]['context'].data == ['zap baz', '']
示例#12
0
def test_linked_manifest_recursion():
    """Test that recursive linked manifests are flagged properly."""

    err = ErrorBundle()
    package = MockXPI({
        "chrome.manifest": "tests/resources/submain/linkman/base1.manifest",
        "submanifest.manifest":
            "tests/resources/submain/linkman/recurse.manifest"})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    print err.print_summary(verbose=True)

    assert err.failed()
    assert not err.notices

    # From the base file:
    assert list(chrome.get_triples(subject="foo"))
    # From the linked manifest:
    assert not list(chrome.get_triples(subject="zap"))
示例#13
0
def test_proper_linked_manifest():
    """Test that linked manifests are imported properly."""

    err = ErrorBundle()
    package = MockXPI({
        "chrome.manifest": "tests/resources/submain/linkman/base1.manifest",
        "submanifest.manifest":
            "tests/resources/submain/linkman/base2.manifest"})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the base file:
    assert list(chrome.get_triples(subject="foo"))
    # From the linked manifest:
    zaps = list(chrome.get_triples(subject="zap"))
    assert zaps
    eq_(zaps[0]["filename"], "submanifest.manifest")
    eq_(zaps[0]["context"].data, ["zap baz", ""])
示例#14
0
def test_populate_chrome_manifest():
    """Ensure that the chrome manifest is populated if available."""

    err = MockErrorHandler(None)
    package_contents = {"chrome.manifest":
            "tests/resources/chromemanifest/chrome.manifest"}
    package = MockXPI(package_contents)

    submain.populate_chrome_manifest(err, MockXPI())
    assert not err.pushable_resources

    submain.populate_chrome_manifest(err, package)
    assert err.pushable_resources
    assert "chrome.manifest" in err.pushable_resources
    print err.pushable_resources
    assert isinstance(err.pushable_resources["chrome.manifest"],
                      ChromeManifest)

    assert err.resources
    assert "chrome.manifest_nopush" in err.resources
    print err.resources
    assert isinstance(err.resources["chrome.manifest_nopush"], ChromeManifest)
示例#15
0
def _do_test(path, test, failure=True,
             require_install=False, set_type=0,
             listed=False, xpi_mode='r'):

    package_data = open(path, 'rb')
    package = XPIManager(package_data, mode=xpi_mode, name=path)
    err = ErrorBundle()
    if listed:
        err.save_resource('listed', True)

    # Populate in the dependencies.
    if set_type:
        err.detected_type = set_type # Conduit test requires type
    if require_install:
        if 'install.rdf' in package:
            err.save_resource('has_install_rdf', True)
            rdf_data = package.read('install.rdf')
            install_rdf = RDFParser(err, rdf_data)
            err.save_resource('install_rdf', install_rdf)
        elif 'manifest.json' in package:
            err.save_resource('has_manifest_json', True)
            manifest_data = package.read('manifest.json')
            manifest_json = ManifestJsonParser(err, manifest_data)
            err.save_resource('install_rdf', manifest_json)

    populate_chrome_manifest(err, package)

    test(err, package)

    print err.print_summary(verbose=True)

    if failure:
        assert err.failed()
    else:
        assert not err.failed()

    return err
示例#16
0
def test_proper_linked_manifest():
    """Test that linked manifests are imported properly."""

    err = ErrorBundle()
    package = MockXPI(
        {
            "chrome.manifest": "tests/resources/submain/linkman/base1.manifest",
            "submanifest.manifest": "tests/resources/submain/linkman/base2.manifest",
        }
    )

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the base file:
    assert list(chrome.get_entries("foo"))
    # From the linked manifest:
    zaps = list(chrome.get_entries("zap"))
    assert zaps
    eq_(zaps[0]["filename"], "submanifest.manifest")
    eq_(zaps[0]["context"].data, ["zap baz", ""])
示例#17
0
def test_linked_manifest_recursion():
    """Test that recursive linked manifests are flagged properly."""

    err = ErrorBundle()
    package = MockXPI(
        {
            "chrome.manifest": "tests/resources/submain/linkman/base1.manifest",
            "submanifest.manifest": "tests/resources/submain/linkman/recurse.manifest",
        }
    )

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    print err.print_summary(verbose=True)

    assert not err.failed()
    assert not err.notices

    # From the base file:
    assert list(chrome.get_entries("foo"))
    # From the linked manifest:
    assert not list(chrome.get_entries("zap"))
示例#18
0
def test_proper_linked_manifest():
    """Test that linked manifests are imported properly."""

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest':
        'tests/resources/submain/linkman/base1.manifest',
        'submanifest.manifest':
        'tests/resources/submain/linkman/base2.manifest'
    })

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed() or err.notices

    # From the base file:
    assert list(chrome.get_triples(subject='foo'))
    # From the linked manifest:
    zaps = list(chrome.get_triples(subject='zap'))
    assert zaps
    assert zaps[0]['filename'] == 'submanifest.manifest'
    assert zaps[0]['context'].data == ['zap baz', '']
示例#19
0
def test_proper_linked_manifest_relative():
    """
    Test that linked manifests are imported relatively when using relative
    paths.
    """

    err = ErrorBundle()
    package = MockXPI({
        "chrome.manifest": "tests/resources/submain/linkman/subdir.manifest",
        "dir/level2.manifest":
            "tests/resources/submain/linkman/foosub.manifest",
        "dir/foo.manifest": "tests/resources/submain/linkman/base2.manifest"})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the linked manifest:
    zaps = list(chrome.get_triples(subject="zap"))
    assert zaps
    eq_(zaps[0]["filename"], "dir/foo.manifest")
    eq_(zaps[0]["context"].data, ["zap baz", ""])
示例#20
0
def test_linked_manifest_recursion():
    """Test that recursive linked manifests are flagged properly."""

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest':
        'tests/resources/submain/linkman/base1.manifest',
        'submanifest.manifest':
        'tests/resources/submain/linkman/recurse.manifest'
    })

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    print err.print_summary(verbose=True)

    assert not err.failed()
    assert not err.notices

    # From the base file:
    assert list(chrome.get_entries('foo'))
    # From the linked manifest:
    assert not list(chrome.get_entries('zap'))
def test_proper_linked_manifest_relative():
    """
    Test that linked manifests are imported relatively when using relative
    paths.
    """

    err = ErrorBundle()
    package = MockXPI({
        'chrome.manifest': 'tests/resources/submain/linkman/subdir.manifest',
        'dir/level2.manifest':
            'tests/resources/submain/linkman/foosub.manifest',
        'dir/foo.manifest': 'tests/resources/submain/linkman/base2.manifest'})

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource('chrome.manifest')
    assert chrome

    assert not err.failed() or err.notices

    # From the linked manifest:
    zaps = list(chrome.get_triples(subject='zap'))
    assert zaps
    assert zaps[0]['filename'] == 'dir/foo.manifest'
    assert zaps[0]['context'].data == ['zap baz', '']