本文整理汇总了Python中validator.errorbundler.ErrorBundle.save_resource方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.save_resource方法的具体用法?Python ErrorBundle.save_resource怎么用?Python ErrorBundle.save_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.errorbundler.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.save_resource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def validate(
path,
format="json",
approved_applications=os.path.join(os.path.dirname(__file__), "app_versions.json"),
determined=True,
spidermonkey=False,
listed=True,
expectation=PACKAGE_ANY,
):
"""Perform validation in one easy step!
format : The format to output the results in
approved_applications : Path to the list of approved application versions
determined : Whether the validator should continue after a tier fails
spidermonkey : Path to the local spidermonkey installation (Default: False)
listed : True if the add-on is destined for AMO, false if not
expectation : The type of package that should be expected
"""
# Load up the target applications
apps = json.load(open(approved_applications))
validator.testcases.targetapplication.APPROVED_APPLICATIONS = apps
bundle = ErrorBundle(listed=listed, determined=determined)
if spidermonkey != False:
bundle.save_resource("SPIDERMONKEY", spidermonkey)
validator.submain.prepare_package(bundle, path, expectation)
# Write the results to the pipe
formats = {"json": lambda b: b.render_json()}
if format is not None:
return formats[format](bundle)
else:
return bundle
示例2: test_jar_nonsubpackage
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_jar_nonsubpackage():
"Tests XPI files that are not subpackages."
err = ErrorBundle()
err.set_type(PACKAGE_MULTI)
err.save_resource("is_multipackage", True)
mock_package = MockXPI(
{"foo.jar":
"tests/resources/content/subpackage.jar",
"chrome/bar.jar":
"tests/resources/content/subpackage.jar"})
content.testendpoint_validator = MockTestEndpoint(("test_inner_package",
"test_package"))
result = content.test_packed_packages(
err,
mock_package)
print result
assert result == 2
content.testendpoint_validator.assert_expectation(
"test_package",
2)
content.testendpoint_validator.assert_expectation(
"test_package",
0,
"subpackage")
示例3: test_duplicate_files
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_duplicate_files():
"""Test that duplicate files in a package are caught."""
err = ErrorBundle()
err.save_resource("has_install_rdf", True)
packagelayout.test_layout_all(err, MockDupeXPI())
assert err.failed()
示例4: _test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def _test(script):
err = ErrorBundle()
err.supported_versions = {}
err.save_resource("em:bootstrap", "true")
scripting.test_js_file(err, "foo", script)
return err
示例5: test_marking_overlays
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_marking_overlays():
"""
Mark an overlay, then test that it marks the scripts within the overlay.
"""
err = ErrorBundle()
err.supported_versions = {}
c = ChromeManifest("""
content ns1 foo/
overlay chrome://foo chrome://ns1/content/main.xul
""", "chrome.manifest")
err.save_resource("chrome.manifest", c)
err.save_resource("chrome.manifest_nopush", c)
xpi = MockXPI({"foo/main.xul": "tests/resources/content/script_list.xul"})
content.test_packed_packages(err, xpi)
assert not err.failed()
marked_scripts = err.get_resource("marked_scripts")
print marked_scripts
assert marked_scripts
eq_(marked_scripts, set(["chrome://ns1/foo.js",
"chrome://ns1/bar.js",
"chrome://asdf/foo.js"]))
示例6: test_marking_overlays_subdir
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_marking_overlays_subdir():
"""
Mark an overlay in a subdirectory, then test that it marks the scripts
within the overlay. Make sure it properly figures out relative URLs.
"""
err = ErrorBundle()
err.supported_versions = {}
c = ChromeManifest("""
content ns1 foo/
overlay chrome://foo chrome://ns1/content/subdir/main.xul
""", 'chrome.manifest')
err.save_resource('chrome.manifest', c)
err.save_resource('chrome.manifest_nopush', c)
xpi = MockXPI({'foo/subdir/main.xul':
'tests/resources/content/script_list.xul'})
content.test_packed_packages(err, xpi)
assert not err.failed()
marked_scripts = err.get_resource('marked_scripts')
print marked_scripts
assert marked_scripts
eq_(marked_scripts, set(['chrome://ns1/subdir/foo.js', 'chrome://ns1/bar.js',
'chrome://asdf/foo.js']))
示例7: setup_err
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def setup_err(package_json=None, err=None):
if err is None:
err = ErrorBundle()
if package_json is not None:
err.save_resource("has_package_json", True)
err.save_resource("package_json", package_json)
return err
示例8: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def _do_test(path, test, failure=True,
require_install=False, set_type=0):
package_data = open(path, "rb")
package = XPIManager(package_data, path)
contents = package.get_file_data()
err = ErrorBundle()
# Populate in the dependencies.
if set_type:
err.set_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(rdf_data)
err.save_resource("install_rdf", install_rdf)
test(err, contents, package)
print err.print_summary(verbose=True)
if failure:
assert err.failed()
else:
assert not err.failed()
return err
示例9: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def _do_test(xpi_package, allow_old_sdk=True, compat=False):
err = ErrorBundle()
if compat:
err.save_resource('is_compat_test', True)
jetpack.inspect_jetpack(err, xpi_package, allow_old_sdk=allow_old_sdk)
return err
示例10: setup_err
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def setup_err(manifest_json=None, err=None):
if err is None:
err = ErrorBundle()
if manifest_json is not None:
err.save_resource('has_manifest_json', True)
err.save_resource('manifest_json', manifest_json)
return err
示例11: test_overlay_object
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_overlay_object():
"""Test that overlay instructions have all its properties."""
err = ErrorBundle()
c = chrome_manifest("""
content namespace /foo/bar
overlay namespace /uri/goes/here
""")
err.save_resource('chrome.manifest', c)
c.get_applicable_overlays(err)
assert not err.failed()
assert not err.notices
err = ErrorBundle()
c = chrome_manifest("""
content namespace /foo/bar
overlay /uri/goes/here
""")
err.save_resource('chrome.manifest', c)
c.get_applicable_overlays(err)
assert err.failed()
assert not err.notices
示例12: test_js_categories_gecko1
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_js_categories_gecko1():
"""Test that JS categories raise problems for space-delimited values."""
c = ChromeManifest("category JavaScript global foo bar", "chrome.manifest")
err = ErrorBundle()
err.save_resource("chrome.manifest", c)
tc_chromemanifest.test_categories(err)
assert err.failed()
示例13: _do_test_raw_webextension
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def _do_test_raw_webextension(manifest, listed=True):
err = ErrorBundle(listed=listed)
manifest = ManifestJsonParser(err, manifest)
err.save_resource('has_manifest_json', True)
err.save_resource('manifest_json', manifest)
targetapp.test_targetedapplications(err)
return err
示例14: test_content_missing_information
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_content_missing_information():
"""Test that incomplete information in a content instruction fails."""
err = ErrorBundle()
c = ChromeManifest("content foo", "chrome.manifest")
err.save_resource("chrome.manifest", c)
tc_chromemanifest.test_content_instructions(err)
assert err.failed()
示例15: test_pass
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import save_resource [as 别名]
def test_pass():
"""Test that standard category subjects pass."""
c = chrome_manifest('category foo bar')
err = ErrorBundle()
err.save_resource('chrome.manifest', c)
tc_chromemanifest.test_categories(err)
assert not err.failed()