当前位置: 首页>>代码示例>>Python>>正文


Python ErrorBundle.get_resource方法代码示例

本文整理汇总了Python中validator.errorbundler.ErrorBundle.get_resource方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.get_resource方法的具体用法?Python ErrorBundle.get_resource怎么用?Python ErrorBundle.get_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator.errorbundler.ErrorBundle的用法示例。


在下文中一共展示了ErrorBundle.get_resource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_validate_libs_in_compat_mode

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_validate_libs_in_compat_mode():
    xpi = "tests/resources/libraryblacklist/addon_with_mootools.xpi"
    with open(xpi) as data:
        package = XPIManager(data, mode="r", name="addon_with_mootools.xpi")
        err = ErrorBundle(for_appversions=FX9_DEFINITION)
        test_content.test_packed_packages(err, package)
    assert err.get_resource("scripts"), "expected mootools scripts to be marked for proessing"
    eq_(err.get_resource("scripts")[0]["scripts"], set(["content/mootools.js"]))
开发者ID:eviljeff,项目名称:amo-validator,代码行数:10,代码来源:test_libraryblacklist.py

示例2: test_doctype

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_doctype():
    "Asserts that install.rdf files with doctypes break validation"

    err = ErrorBundle()
    xpi = MockXPIManager(
            {"install.rdf": "tests/resources/installrdf/doctype.rdf"})
    submain._load_install_rdf(err, xpi, None)
    assert err.failed()
    assert not err.get_resource("has_install_rdf")
    assert not err.get_resource("install_rdf")
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:12,代码来源:test_submain_install_rdf.py

示例3: test_validate_libs_in_compat_mode

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_validate_libs_in_compat_mode():
    xpi = 'tests/resources/libraryblacklist/addon_with_mootools.xpi'
    with open(xpi) as data:
        package = XPIManager(data, mode='r', name='addon_with_mootools.xpi')
        appversions = {FIREFOX_GUID: version_range('firefox',
                                                   '39.0a1', '39.*')}
        err = ErrorBundle(for_appversions=appversions)
        test_content.test_packed_packages(err, package)
    assert err.get_resource('scripts'), (
                    'expected mootools scripts to be marked for proessing')
    assert err.get_resource('scripts')[0]['scripts'] == set(['content/mootools.js'])
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:13,代码来源:test_libraryblacklist.py

示例4: test_initializer

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_initializer():
    """Test that the __init__ paramaters are doing their jobs."""

    e = ErrorBundle()
    assert e.determined
    assert e.get_resource("listed")

    e = ErrorBundle(determined=False)
    assert not e.determined
    assert e.get_resource("listed")

    e = ErrorBundle(listed=False)
    assert e.determined
    assert not e.get_resource("listed")
开发者ID:kmaglione,项目名称:amo-validator,代码行数:16,代码来源:test_errorbundler.py

示例5: test_pushable_resources

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_pushable_resources():
    """
    Test that normal resources are preserved but pushable ones are pushed.
    """

    e = ErrorBundle()
    e.save_resource("nopush", True)
    e.save_resource("push", True, pushable=True)

    assert e.get_resource("nopush")
    assert e.get_resource("push")

    e.push_state()

    assert e.get_resource("nopush")
    assert not e.get_resource("push")

    e.save_resource("pushed", True, pushable=True)
    assert e.get_resource("pushed")

    e.pop_state()

    assert e.get_resource("nopush")
    assert e.get_resource("push")
    assert not e.get_resource("pushed")
开发者ID:kmaglione,项目名称:amo-validator,代码行数:27,代码来源:test_errorbundler.py

示例6: test_marking_overlays_subdir

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_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']))
开发者ID:diox,项目名称:amo-validator,代码行数:29,代码来源:test_content_overlays.py

示例7: test_marking_overlays

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_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"]))
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:28,代码来源:test_content_overlays.py

示例8: test_proper_linked_manifest_relative

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
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", ""])
开发者ID:kmaglione,项目名称:amo-validator,代码行数:28,代码来源:test_submain.py

示例9: test_version_forappversions_accepted

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_version_forappversions_accepted():
    """
    Test that for_appversions targets application versions properly.
    """

    err = ErrorBundle()
    err.supported_versions = {'firefox': ['1.2.3']}

    tests = decorator.TEST_TIERS
    decorator.TEST_TIERS = {}

    @decorator.register_test(tier=5, versions={'firefox': ['1.0.0',
                                                           '1.2.3']})
    def version_test(err, xpi):
        print 'Ran test'
        err.save_resource('executed', True)

    print decorator.TEST_TIERS

    validator.submain.test_inner_package(err, MockXPI(),
                                         for_appversions={'firefox':
                                                              ['1.2.3']})

    assert err.get_resource('executed')
    decorator.TEST_TIERS = tests
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:27,代码来源:test_submain_versions.py

示例10: test_package_pass

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_package_pass(test_inner_package):
    'Tests the test_package function with simple data'

    err = ErrorBundle()
    with open('tests/resources/submain/install_rdf.xpi') as pkg:
        submain.test_package(err, pkg, pkg.name)

    assert not err.failed()
    assert err.get_resource('has_install_rdf')
    assert submain.test_inner_package.called
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:12,代码来源:test_submain_package.py

示例11: test_package_extension_expectation

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_package_extension_expectation(test_inner_package):
    'Tests the test_package function with an odd extension'

    err = ErrorBundle()
    with open('tests/resources/submain/install_rdf.jar') as pkg:
        submain.test_package(err, pkg, pkg.name, PACKAGE_ANY)

    assert submain.test_inner_package.called
    assert not err.failed()
    assert err.get_resource('has_install_rdf')
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:12,代码来源:test_submain_package.py

示例12: test_package_extension_expectation

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def test_package_extension_expectation():
    "Tests the test_package function with an odd extension"

    tip = submain.test_inner_package
    submain.test_inner_package = lambda x, z, for_appversions: "success"

    name = "tests/resources/submain/install_rdf.jar"
    err = ErrorBundle()

    result = submain.test_package(err, name, name, PACKAGE_ANY)

    submain.test_inner_package = tip

    assert not err.failed()
    assert err.get_resource("has_install_rdf")
    assert result == "success"
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:18,代码来源:test_submain_package.py

示例13: _run_test

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
def _run_test(filename, expectation, should_fail=True):

    name = "tests/resources/submain/%s" % filename
    pack = open(name)
    xpi = XPIManager(pack, mode="r", name=name)
    err = ErrorBundle(None, True)

    submain._load_install_rdf(err, xpi, expectation)

    if should_fail:
        assert err.failed()
    else:
        assert not err.failed()
        assert err.get_resource("install_rdf")

    return err
开发者ID:Archaeopteryx,项目名称:amo-validator,代码行数:18,代码来源:test_submain_install_rdf.py

示例14: test_missing_manifest_link

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
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"))
开发者ID:kmaglione,项目名称:amo-validator,代码行数:19,代码来源:test_submain.py

示例15: test_missing_manifest_link

# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import get_resource [as 别名]
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'))
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:20,代码来源:test_submain.py


注:本文中的validator.errorbundler.ErrorBundle.get_resource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。