Pass compat flag to validator during bulk validation (bug 735841)

This commit is contained in:
Matt Basta 2012-09-04 11:54:48 -07:00
Родитель b61a0acfee
Коммит 7936dda357
4 изменённых файлов: 26 добавлений и 9 удалений

Просмотреть файл

@ -99,7 +99,7 @@ def file_validator(file_id, **kw):
def run_validator(file_path, for_appversions=None, test_all_tiers=False, 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. """A pre-configured wrapper around the addon validator.
*file_path* *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. few things we need to override. See validator for supported overrides.
Example: {'targetapp_maxVersion': {'<app guid>': '<version>'}} 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, To validate the addon for compatibility with Firefox 5 and 6,
you'd pass in:: 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 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 apps = dump_apps.Command.JSON_PATH
if not os.path.exists(apps): if not os.path.exists(apps):
call_command('dump_apps') call_command('dump_apps')
@ -160,7 +159,8 @@ def run_validator(file_path, for_appversions=None, test_all_tiers=False,
approved_applications=apps, approved_applications=apps,
spidermonkey=settings.SPIDERMONKEY, spidermonkey=settings.SPIDERMONKEY,
overrides=overrides, overrides=overrides,
timeout=settings.VALIDATOR_TIMEOUT) timeout=settings.VALIDATOR_TIMEOUT,
compat_test=compat)
finally: finally:
if temp: if temp:
os.remove(path) os.remove(path)

Просмотреть файл

@ -268,6 +268,13 @@ class TestValidateFile(BaseUploadTest):
addon = Addon.objects.get(pk=self.addon.id) addon = Addon.objects.get(pk=self.addon.id)
eq_(addon.binary, True) 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') @mock.patch('devhub.tasks.run_validator')
def test_ending_tier_is_preserved(self, v): def test_ending_tier_is_preserved(self, v):
v.return_value = json.dumps({ v.return_value = json.dumps({

Просмотреть файл

@ -90,7 +90,8 @@ def bulk_validate_file(result_id, **kw):
'targetapp_maxVersion': 'targetapp_maxVersion':
{target.application.guid: target.version}} {target.application.guid: target.version}}
validation = run_validator(res.file.file_path, for_appversions=ver, 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: except:
task_error = sys.exc_info() task_error = sys.exc_info()
log.error(u"bulk_validate_file exception on file %s (%s): %s: %s" 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)) % (self.curr_max.version, self.new_max.version))
eq_(mail.outbox[0].to, ['fliggy@mozilla.com']) 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') @mock.patch('zadmin.tasks.run_validator')
def test_task_error(self, run_validator): def test_task_error(self, run_validator):
run_validator.side_effect = RuntimeError('validation error') run_validator.side_effect = RuntimeError('validation error')