Chaos chimp updates
This commit is contained in:
Родитель
867e61687f
Коммит
4736940263
|
@ -0,0 +1 @@
|
|||
{"1":{"name":"Foo App", "guid":"abc123foobar", "versions":["f00"]}}
|
|
@ -45,7 +45,7 @@ four def abc""")
|
|||
def test_incomplete_triplets():
|
||||
"Tests that incomplete triplets are ignored"
|
||||
|
||||
c = ChromeManifest("foo\nabc def")
|
||||
c = ChromeManifest("foo\nbar")
|
||||
assert not c.triples
|
||||
|
||||
def test_duplicate_subjects():
|
||||
|
|
|
@ -5,13 +5,29 @@ from StringIO import StringIO
|
|||
import validator.xpi as xpi
|
||||
import validator.testcases.content as content
|
||||
from validator.errorbundler import ErrorBundle
|
||||
from validator.chromemanifest import ChromeManifest
|
||||
from helper import _do_test
|
||||
from validator.constants import *
|
||||
|
||||
def test_xpcnativewrappers():
|
||||
"Tests that xpcnativewrappers is not in the chrome.manifest"
|
||||
|
||||
err = ErrorBundle()
|
||||
|
||||
err.save_resource("chrome.manifest",
|
||||
ChromeManifest("foo bar"))
|
||||
content.test_xpcnativewrappers(err, {}, None)
|
||||
assert not err.failed()
|
||||
|
||||
err.save_resource("chrome.manifest",
|
||||
ChromeManifest("xpcnativewrappers on"))
|
||||
content.test_xpcnativewrappers(err, {}, None)
|
||||
assert err.failed()
|
||||
|
||||
def test_ignore_macstuff():
|
||||
"Tests that the content manager will ignore Mac-generated files"
|
||||
|
||||
err = ErrorBundle(None, True)
|
||||
err = ErrorBundle()
|
||||
result = content.test_packed_packages(err,
|
||||
{"__MACOSX": None,
|
||||
"__MACOSX/foo": None,
|
||||
|
|
|
@ -4,6 +4,7 @@ def test_tiers():
|
|||
"""Tests to make sure that the decorator module is properly
|
||||
registering test functions."""
|
||||
|
||||
dtt = decorator.TEST_TIERS
|
||||
decorator.TEST_TIERS = {}
|
||||
|
||||
decorator.register_test(tier=1)(lambda: None)
|
||||
|
@ -14,11 +15,13 @@ def test_tiers():
|
|||
tiers = decorator.get_tiers()
|
||||
print tiers
|
||||
assert len(tiers) == 2
|
||||
decorator.TEST_TIERS = dtt
|
||||
|
||||
def test_specifictype():
|
||||
"""Tests to make sure that the decorator module can return a test
|
||||
of a specific type."""
|
||||
|
||||
dtt = decorator.TEST_TIERS
|
||||
decorator.TEST_TIERS = {}
|
||||
|
||||
decorator.register_test(tier=1)(lambda: None)
|
||||
|
@ -28,11 +31,13 @@ def test_specifictype():
|
|||
|
||||
tests = list(decorator.get_tests(2, 1))
|
||||
assert len(tests) == 2
|
||||
decorator.TEST_TIERS = dtt
|
||||
|
||||
def test_assumedtype():
|
||||
"""Tests to see if the decorator module can find tests for generic
|
||||
as well as specific types"""
|
||||
|
||||
dtt = decorator.TEST_TIERS
|
||||
decorator.TEST_TIERS = {}
|
||||
|
||||
decorator.register_test(tier=1)(lambda: None)
|
||||
|
@ -42,4 +47,5 @@ def test_assumedtype():
|
|||
|
||||
tests = list(decorator.get_tests(2, 5))
|
||||
assert len(tests) == 3
|
||||
|
||||
decorator.TEST_TIERS = dtt
|
||||
|
||||
|
|
|
@ -224,3 +224,18 @@ def test_notice_friendly():
|
|||
|
||||
assert output.count("foobar")
|
||||
|
||||
def test_initializer():
|
||||
"Tests 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")
|
||||
|
||||
|
|
|
@ -75,6 +75,19 @@ def test_has_chrome_manifest():
|
|||
"""Makes sure the module fails when a chrome.manifest file is not
|
||||
available."""
|
||||
|
||||
assert langpack.test_langpack_manifest(None,
|
||||
assert langpack.test_langpack_manifest(ErrorBundle(),
|
||||
{},
|
||||
None) is None
|
||||
|
||||
def test_valid_chrome_manifest():
|
||||
"Chrome manifests must only contain certain elements"
|
||||
|
||||
err = ErrorBundle()
|
||||
err.save_resource("chrome.manifest", ChromeManifest("locale foo bar"))
|
||||
langpack.test_langpack_manifest(err, {}, None)
|
||||
assert not err.failed()
|
||||
|
||||
err.save_resource("chrome.manifest", ChromeManifest("foo bar asdf"))
|
||||
langpack.test_langpack_manifest(err, {}, None)
|
||||
assert err.failed()
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ def test_prepare_package_bad_file():
|
|||
def test_prepare_package_xml():
|
||||
"Tests that the prepare_package function passes with search providers"
|
||||
|
||||
smts = submain.test_search
|
||||
submain.test_search = lambda err,y,z: True
|
||||
|
||||
err = ErrorBundle(None, True)
|
||||
|
@ -45,12 +46,14 @@ def test_prepare_package_xml():
|
|||
submain.prepare_package(err, "tests/resources/main/foo.xml")
|
||||
|
||||
assert err.failed()
|
||||
submain.test_search = smts
|
||||
|
||||
# Test the function of the decorator iterator
|
||||
|
||||
def test_test_inner_package():
|
||||
"Tests that the test_inner_package function works properly"
|
||||
|
||||
smd = submain.decorator
|
||||
decorator = MockDecorator()
|
||||
submain.decorator = decorator
|
||||
err = MockErrorHandler(decorator)
|
||||
|
@ -58,10 +61,12 @@ def test_test_inner_package():
|
|||
submain.test_inner_package(err, "foo", "bar")
|
||||
|
||||
assert not err.failed()
|
||||
submain.decorator = smd
|
||||
|
||||
def test_test_inner_package_failtier():
|
||||
"Tests that the test_inner_package function fails at a failed tier"
|
||||
|
||||
smd = submain.decorator
|
||||
decorator = MockDecorator(3)
|
||||
submain.decorator = decorator
|
||||
err = MockErrorHandler(decorator)
|
||||
|
@ -69,10 +74,13 @@ def test_test_inner_package_failtier():
|
|||
submain.test_inner_package(err, "foo", "bar")
|
||||
|
||||
assert err.failed()
|
||||
submain.decorator = smd
|
||||
|
||||
# Test chrome.manifest populator
|
||||
|
||||
def test_populate_chrome_manifest():
|
||||
"Ensures that the chrome manifest is populated if available"
|
||||
|
||||
err = MockErrorHandler(None)
|
||||
package_contents = {"chrome.manifest":{"foo":"bar"}}
|
||||
package = MockXPIPackage(package_contents)
|
||||
|
@ -94,6 +102,7 @@ def test_populate_chrome_manifest():
|
|||
def test_test_inner_package_determined():
|
||||
"Tests that the determined test_inner_package function works properly"
|
||||
|
||||
smd = submain.decorator
|
||||
decorator = MockDecorator(None, True)
|
||||
submain.decorator = decorator
|
||||
err = MockErrorHandler(decorator, True)
|
||||
|
@ -102,10 +111,12 @@ def test_test_inner_package_determined():
|
|||
|
||||
assert not err.failed()
|
||||
assert decorator.last_tier == 5
|
||||
submain.decorator = smd
|
||||
|
||||
def test_test_inner_package_failtier():
|
||||
"Tests the test_inner_package function in determined mode while failing"
|
||||
|
||||
smd = submain.decorator
|
||||
decorator = MockDecorator(3, True)
|
||||
submain.decorator = decorator
|
||||
err = MockErrorHandler(decorator, True)
|
||||
|
@ -114,6 +125,7 @@ def test_test_inner_package_failtier():
|
|||
|
||||
assert err.failed()
|
||||
assert decorator.last_tier == 5
|
||||
submain.decorator = smd
|
||||
|
||||
class MockDecorator:
|
||||
|
||||
|
|
|
@ -13,10 +13,14 @@ def test_valid_targetapps():
|
|||
|
||||
print targetapp.APPROVED_APPLICATIONS
|
||||
|
||||
_do_test("tests/resources/targetapplication/pass.xpi",
|
||||
targetapp.test_targetedapplications,
|
||||
False,
|
||||
True)
|
||||
results = _do_test("tests/resources/targetapplication/pass.xpi",
|
||||
targetapp.test_targetedapplications,
|
||||
False,
|
||||
True)
|
||||
print results.get_resource("supports")
|
||||
supports = results.get_resource("supports")
|
||||
assert "firefox" in supports and "mozilla" in supports
|
||||
assert len(supports) == 2
|
||||
|
||||
def test_bad_min_max():
|
||||
"""Tests that the lower/upper-bound version number for a
|
||||
|
@ -68,3 +72,6 @@ def test_is_ff4():
|
|||
True)
|
||||
|
||||
assert results.get_resource("ff4")
|
||||
assert results.get_resource("supports")
|
||||
assert "firefox" in results.get_resource("supports")
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import validator.testcases.themes as themes
|
||||
from validator.chromemanifest import ChromeManifest
|
||||
from validator.errorbundler import ErrorBundle
|
||||
from helper import _do_test
|
||||
|
||||
def test_theme_chrome_manifest():
|
||||
|
@ -18,4 +18,4 @@ def test_theme_bad_chrome_manifest():
|
|||
def test_no_chrome_manifest():
|
||||
"Tests that validation is skipped if there is no chrome manifest."
|
||||
|
||||
assert themes.test_theme_manifest(None, {}, None) is None
|
||||
assert themes.test_theme_manifest(ErrorBundle(), {}, None) is None
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import json
|
||||
from validator.validate import validate as validate
|
||||
from validator.errorbundler import ErrorBundle
|
||||
import validator.testcases.targetapplication as targetapp
|
||||
|
||||
def test_validate():
|
||||
output = validate(path="tests/resources/packagelayout/theme.jar")
|
||||
j = json.loads(output)
|
||||
print j
|
||||
assert j["metadata"]["name"] == "name_value"
|
||||
|
||||
output = validate(path="tests/resources/packagelayout/theme.jar",
|
||||
format=None)
|
||||
assert isinstance(output, ErrorBundle)
|
||||
assert output.metadata["name"] == "name_value"
|
||||
assert output.get_resource("SPIDERMONKEY") == False
|
||||
|
||||
output = validate(path="tests/resources/packagelayout/theme.jar",
|
||||
spidermonkey="foospidermonkey",
|
||||
format=None)
|
||||
assert output.get_resource("SPIDERMONKEY") == "foospidermonkey"
|
||||
assert output.determined
|
||||
assert output.get_resource("listed")
|
||||
|
||||
output = validate(path="tests/resources/packagelayout/theme.jar",
|
||||
determined=False,
|
||||
format=None)
|
||||
assert not output.determined
|
||||
assert output.get_resource("listed")
|
||||
|
||||
output = validate(path="tests/resources/packagelayout/theme.jar",
|
||||
listed=False,
|
||||
format=None)
|
||||
assert output.determined
|
||||
assert not output.get_resource("listed")
|
||||
|
||||
def test_app_versions():
|
||||
"Tests that the validate function properly loads app_versions.json"
|
||||
validate(path="tests/resources/junk.xpi",
|
||||
approved_applications="tests/resources/test_app_versions.json")
|
||||
assert targetapp.APPROVED_APPLICATIONS["1"]["name"] == "Foo App"
|
||||
|
|
@ -23,8 +23,13 @@ class ChromeManifest(object):
|
|||
continue
|
||||
|
||||
triple = line.split(None, 2)
|
||||
if not triple or len(triple) < 3:
|
||||
if not triple:
|
||||
continue
|
||||
elif len(triple) == 2:
|
||||
triple.append("")
|
||||
if len(triple) < 3:
|
||||
continue
|
||||
|
||||
|
||||
triples.append({"subject": triple[0],
|
||||
"predicate": triple[1],
|
||||
|
|
|
@ -19,20 +19,13 @@ def test_xpcnativewrappers(err, package_contents=None, xpi_package=None):
|
|||
xpcnativewrappers objects."""
|
||||
|
||||
# Don't even both with the test(s) if there's no chrome.manifest.
|
||||
if "chrome.manifest" not in package_contents:
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
if not chrome:
|
||||
return None
|
||||
|
||||
# Retrieve the chrome.manifest if it's cached.
|
||||
if err.get_resource("chrome.manifest"): # pragma: no cover
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
else:
|
||||
chrome_data = xpi_package.read("chrome.manifest")
|
||||
chrome = ChromeManifest(chrome_data)
|
||||
err.save_resource("chrome.manifest", chrome)
|
||||
|
||||
for triple in chrome.triples:
|
||||
# Test to make sure that the triple's subject is valid
|
||||
if [True for t in triple if t.startswith("xpcnativewrappers")]:
|
||||
if triple["subject"] == "xpcnativewrappers":
|
||||
err.warning(("testcases_content",
|
||||
"test_xpcnativewrappers",
|
||||
"found_in_chrome_manifest"),
|
||||
|
@ -116,9 +109,9 @@ def test_packed_packages(err, package_contents=None, xpi_package=None):
|
|||
testendpoint_validator.test_inner_package(err,
|
||||
temp_contents,
|
||||
sub_xpi)
|
||||
err.set_tier(2)
|
||||
package.close()
|
||||
err.pop_state()
|
||||
err.set_tier(2)
|
||||
|
||||
elif data["extension"] == "xpi":
|
||||
# It's not a subpackage, it's a nested extension. These are
|
||||
|
@ -181,11 +174,10 @@ def _read_error(err, name): # pragma: no cover
|
|||
"""Reports to the user that a file in the archive couldn't be
|
||||
read from. Prevents code duplication."""
|
||||
|
||||
err.info(("testcases_content",
|
||||
"_read_error",
|
||||
"read_error"),
|
||||
"File could not be read: %s" % name,
|
||||
"""A File in the archive could not be read. This may be
|
||||
due to corruption or because the path name is too
|
||||
long.""",
|
||||
name)
|
||||
err.notice(("testcases_content",
|
||||
"_read_error",
|
||||
"read_error"),
|
||||
"File could not be read: %s" % name,
|
||||
"A File in the archive could not be read. This may be due to "
|
||||
"corruption or because the path name is too long.",
|
||||
name)
|
||||
|
|
|
@ -14,18 +14,10 @@ def test_langpack_manifest(err, package_contents=None, xpi_package=None):
|
|||
compliance with the standard language pack triples."""
|
||||
|
||||
# Don't even both with the test(s) if there's no chrome.manifest.
|
||||
if "chrome.manifest" not in package_contents:
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
if not chrome:
|
||||
return
|
||||
|
||||
# Retrieve the chrome.manifest if it's cached.
|
||||
if err.get_resource("chrome.manifest"): # pragma: no cover
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
else:
|
||||
# Presence is tested by the packagelayout module.
|
||||
chrome_data = xpi_package.read("chrome.manifest")
|
||||
chrome = ChromeManifest(chrome_data)
|
||||
err.save_resource("chrome.manifest", chrome)
|
||||
|
||||
for triple in chrome.triples:
|
||||
subject = triple["subject"]
|
||||
# Test to make sure that the triple's subject is valid
|
||||
|
|
|
@ -36,8 +36,6 @@ def test_targetedapplications(err, package_contents=None,
|
|||
|
||||
used_targets = [];
|
||||
|
||||
mismatch_pattern = "Version numbers for %s are invalid."
|
||||
|
||||
# Isolate all of the bnodes referring to target applications
|
||||
for target_app in install.get_objects(None, ta_predicate):
|
||||
|
||||
|
|
|
@ -9,16 +9,9 @@ def test_theme_manifest(err, package_contents=None, xpi_package=None):
|
|||
compliance with the standard theme triples."""
|
||||
|
||||
# Don't even both with the test(s) if there's no chrome.manifest.
|
||||
if "chrome.manifest" not in package_contents:
|
||||
return None
|
||||
|
||||
# Retrieve the chrome.manifest if it's cached.
|
||||
if err.get_resource("chrome.manifest"): # pragma: no cover
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
else:
|
||||
chrome_data = xpi_package.read("chrome.manifest")
|
||||
chrome = ChromeManifest(chrome_data)
|
||||
err.save_resource("chrome.manifest", chrome)
|
||||
chrome = err.get_resource("chrome.manifest")
|
||||
if not chrome:
|
||||
return
|
||||
|
||||
for triple in chrome.triples:
|
||||
subject = triple["subject"]
|
||||
|
|
Загрузка…
Ссылка в новой задаче