def test_validation_error(self, _mock): _mock.side_effect = Exception eq_(self.upload.task_error, None) tasks.validator(self.upload.pk) error = self.get_upload().task_error assert error is not None assert error.startswith('Traceback (most recent call last)'), error
def test_validate_packaged_app(self, _zipfile, _mock): _zipfile.return_value = True _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) assert _mock.called
def test_validate_manifest(self, _open, _mock): _open.return_value = tempfile.TemporaryFile() _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) assert _mock.called
def test_fail_validation(self, _mock): _mock.return_value = '{"errors": 2}' tasks.validator(self.upload.pk) assert not self.get_upload().valid
return # Check hash. if check_hash: hash_ = _get_content_hash(content) if file_.hash == hash_: _log(webapp, u'Manifest the same') return _log(webapp, u'Manifest different') # Validate the new manifest. upload = FileUpload.objects.create() upload.add_file([content], webapp.manifest_url, len(content), is_webapp=True) validator(upload.pk) upload = FileUpload.objects.get(pk=upload.pk) if upload.validation: v8n = json.loads(upload.validation) if v8n['errors']: v8n_url = absolutify(reverse( 'mkt.developers.upload_detail', args=[upload.uuid])) msg = u'Validation errors:\n' for m in v8n['messages']: if m['type'] == u'error': msg += u'* %s\n' % m['message'] msg += u'\nValidation Result:\n%s' % v8n_url _log(webapp, msg, rereview=True) if webapp.status in amo.WEBAPPS_APPROVED_STATUSES: notify_developers_of_failure(webapp, msg, has_link=True)
def test_validate_packaged_app(self, _zipfile, _mock): self.get_upload().update(is_webapp=True) _zipfile.return_value = True _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) assert _mock.called
def test_validate_manifest(self, _open, _mock): self.get_upload().update(is_webapp=True) _open.return_value = StringIO('') _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) assert _mock.called
def test_validate_manifest(self, _open, _mock): _open.return_value = StringIO('') _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) assert _mock.called
def test_validate_any_package(self, _mock): _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) # Let validator determine by file extension. eq_(_mock.call_args[1]['expectation'], validator.constants.PACKAGE_ANY)
def test_validate_manifest(self, _mock): self.get_upload().update(is_webapp=True) _mock.return_value = '{"errors": 0}' tasks.validator(self.upload.pk) eq_(_mock.call_args[1]['expectation'], validator.constants.PACKAGE_WEBAPP)