Pass compat flag to validator during bulk validation (bug 735841)
This commit is contained in:
Родитель
b61a0acfee
Коммит
7936dda357
|
@ -99,7 +99,7 @@ def file_validator(file_id, **kw):
|
|||
|
||||
|
||||
def run_validator(file_path, for_appversions=None, test_all_tiers=False,
|
||||
overrides=None):
|
||||
overrides=None, compat=False):
|
||||
"""A pre-configured wrapper around the addon validator.
|
||||
|
||||
*file_path*
|
||||
|
@ -120,6 +120,11 @@ def run_validator(file_path, for_appversions=None, test_all_tiers=False,
|
|||
few things we need to override. See validator for supported overrides.
|
||||
Example: {'targetapp_maxVersion': {'<app guid>': '<version>'}}
|
||||
|
||||
*compat=False*
|
||||
Set this to `True` when performing a bulk validation. This allows the
|
||||
validator to ignore certain tests that should not be run during bulk
|
||||
validation (see bug 735841).
|
||||
|
||||
To validate the addon for compatibility with Firefox 5 and 6,
|
||||
you'd pass in::
|
||||
|
||||
|
@ -131,12 +136,6 @@ def run_validator(file_path, for_appversions=None, test_all_tiers=False,
|
|||
|
||||
from validator.validate import validate
|
||||
|
||||
# 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')
|
||||
|
@ -160,7 +159,8 @@ def run_validator(file_path, for_appversions=None, test_all_tiers=False,
|
|||
approved_applications=apps,
|
||||
spidermonkey=settings.SPIDERMONKEY,
|
||||
overrides=overrides,
|
||||
timeout=settings.VALIDATOR_TIMEOUT)
|
||||
timeout=settings.VALIDATOR_TIMEOUT,
|
||||
compat_test=compat)
|
||||
finally:
|
||||
if temp:
|
||||
os.remove(path)
|
||||
|
|
|
@ -268,6 +268,13 @@ class TestValidateFile(BaseUploadTest):
|
|||
addon = Addon.objects.get(pk=self.addon.id)
|
||||
eq_(addon.binary, True)
|
||||
|
||||
@mock.patch('validator.validate.validate')
|
||||
def test_validator_sets_binary_flag_for_extensions(self, v):
|
||||
r = self.client.post(reverse('devhub.json_file_validation',
|
||||
args=[self.addon.slug, self.file.id]),
|
||||
follow=True)
|
||||
assert not v.call_args[1].get('compat_test', True)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
def test_ending_tier_is_preserved(self, v):
|
||||
v.return_value = json.dumps({
|
||||
|
|
|
@ -90,7 +90,8 @@ def bulk_validate_file(result_id, **kw):
|
|||
'targetapp_maxVersion':
|
||||
{target.application.guid: target.version}}
|
||||
validation = run_validator(res.file.file_path, for_appversions=ver,
|
||||
test_all_tiers=True, overrides=overrides)
|
||||
test_all_tiers=True, overrides=overrides,
|
||||
compat=True)
|
||||
except:
|
||||
task_error = sys.exc_info()
|
||||
log.error(u"bulk_validate_file exception on file %s (%s): %s: %s"
|
||||
|
|
|
@ -739,6 +739,15 @@ class TestBulkValidationTask(BulkValidationTest):
|
|||
% (self.curr_max.version, self.new_max.version))
|
||||
eq_(mail.outbox[0].to, ['fliggy@mozilla.com'])
|
||||
|
||||
@mock.patch('validator.validate.validate')
|
||||
def test_validator_bulk_compat_flag(self, validate):
|
||||
try:
|
||||
self.start_validation()
|
||||
except Exception:
|
||||
# We only care about the call to `validate()`, not the result.
|
||||
pass
|
||||
assert validate.call_args[1].get('compat_test')
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
def test_task_error(self, run_validator):
|
||||
run_validator.side_effect = RuntimeError('validation error')
|
||||
|
|
Загрузка…
Ссылка в новой задаче