def run_validator(file_path, for_appversions=None, test_all_tiers=False, overrides=None, force_validation_type=None): """A pre-configured wrapper around the addon validator. *file_path* Path to addon / extension file to validate. *for_appversions=None* An optional dict of application versions to validate this addon for. The key is an application GUID and its value is a list of versions. *test_all_tiers=False* When False (default) the validator will not continue if it encounters fatal errors. When True, all tests in all tiers are run. See bug 615426 for discussion on this default. *overrides=None* Normally the validator gets info from install.rdf but there are a few things we need to override. See validator for supported overrides. Example: {'targetapp_maxVersion': {'<app guid>': '<version>'}} *force_validation_type=None* Set this to a value in validator.constants like PACKAGE_WEBAPP when you need to force detection of a package. Otherwise the type will be inferred from the filename extension. To validate the addon for compatibility with Firefox 5 and 6, you'd pass in:: for_appversions={amo.FIREFOX.guid: ['5.0.*', '6.0.*']} Not all application versions will have a set of registered compatibility tests. """ from validator.validate import validate_app # TODO(Kumar) remove this when validator is fixed, see bug 620503 from validator.testcases import scripting scripting.SPIDERMONKEY_INSTALLATION = settings.SPIDERMONKEY import validator.constants validator.constants.SPIDERMONKEY_INSTALLATION = settings.SPIDERMONKEY apps = dump_apps.Command.JSON_PATH if not os.path.exists(apps): call_command('dump_apps') if not force_validation_type: force_validation_type = validator.constants.PACKAGE_ANY with statsd.timer('mkt.developers.validator'): return validate_app( storage.open(file_path).read() if file_path else '', market_urls=settings.VALIDATOR_IAF_URLS)
def test_webapp_new(): """Test that webapps can be validated with the new api.""" with open("tests/resources/testwebapp.webapp") as file_: out = validate_app(file_.read()) j = json.loads(out) assert j["success"], "Expected not to fail"