Passes min-version to validator so it can ignore irrelvant tests (bug 675306)

This commit is contained in:
Kumar McMillan 2011-07-29 17:15:17 -05:00
Родитель 91f5512d5b
Коммит 4143bdcb11
2 изменённых файлов: 27 добавлений и 2 удалений

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

@ -65,8 +65,19 @@ def bulk_validate_file(result_id, **kw):
% (res.file, file_base, res.id)) % (res.file, file_base, res.id))
target = res.validation_job.target_version target = res.validation_job.target_version
ver = {target.application.guid: [target.version]} ver = {target.application.guid: [target.version]}
overrides = {"targetapp_maxVersion": overrides = {'targetapp_maxVersion':
{target.application.guid: target.version}} {target.application.guid: target.version}}
qs = res.file.version.apps.filter(application=target.application)
if qs.count() == 1:
# This addon version is already compatible with some version
# of <app>. This tells the validator to ignore some
# irrelevant tests
minver = {target.application.guid: qs[0].max.version}
overrides['targetapp_minVersion'] = minver
else:
log.info('bulk_validate_file maxVersion not defined '
'(or duplicated) for file %s (%s), application %s'
% (res.file, file_base, target.application))
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)
except: except:

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

@ -738,8 +738,22 @@ class TestBulkValidationTask(BulkValidationTest):
validate.return_value = json.dumps(no_op_validation) validate.return_value = json.dumps(no_op_validation)
self.start_validation(new_max='3.7a4') self.start_validation(new_max='3.7a4')
assert validate.called assert validate.called
overrides = validate.call_args[1]['overrides']
eq_(overrides['targetapp_maxVersion'], {amo.FIREFOX.guid: '3.7a4'})
minver = self.version.apps.filter(
application=amo.FIREFOX.id)[0].max.version
eq_(overrides['targetapp_minVersion'], {amo.FIREFOX.guid: minver})
@mock.patch('validator.validate.validate')
def test_no_min_appversion(self, validate):
validate.return_value = json.dumps(no_op_validation)
self.version.apps.all().delete()
job = self.create_job(target_version=self.appversion('3.7a4'))
res = self.create_result(job, self.create_file(), **{})
tasks.bulk_validate_file(res.id)
assert validate.called
eq_(validate.call_args[1]['overrides'], eq_(validate.call_args[1]['overrides'],
{"targetapp_maxVersion": {amo.FIREFOX.guid: '3.7a4'}}) {'targetapp_maxVersion': {amo.FIREFOX.guid: '3.7a4'}})
def create_version(self, addon, statuses, version_str=None): def create_version(self, addon, statuses, version_str=None):
max = self.max max = self.max