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', '']
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", ""])
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
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
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"))
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'))
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"))
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', '']
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 eq_(zaps[0]["filename"], "submanifest.manifest") eq_(zaps[0]["context"].data, ["zap baz", ""])
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)
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
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", ""])
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(): """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', '']
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", ""])
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', '']