本文整理汇总了Python中mkt.developers.tasks.validator函数的典型用法代码示例。如果您正苦于以下问题:Python validator函数的具体用法?Python validator怎么用?Python validator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validator函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validation_error
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
示例2: _get_content_hash
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)
示例3: test_validate_packaged_app
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
示例4: test_validate_manifest
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
示例5: test_fail_validation
def test_fail_validation(self, _mock):
_mock.return_value = '{"errors": 2}'
tasks.validator(self.upload.pk)
assert not self.get_upload().valid
示例6: test_validate_manifest
def test_validate_manifest(self, _open, _mock):
_open.return_value = StringIO('')
_mock.return_value = '{"errors": 0}'
tasks.validator(self.upload.pk)
assert _mock.called
示例7: test_validate_manifest
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
示例8: test_validate_any_package
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)
示例9: test_validate_manifest
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)