本文整理汇总了Python中mkt.developers.tasks.fetch_manifest函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_manifest函数的具体用法?Python fetch_manifest怎么用?Python fetch_manifest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch_manifest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_other_url_error
def test_other_url_error(self):
reason = Exception('Some other failure.')
self.urlopen_mock.side_effect = urllib2.URLError(reason)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:rtnpro,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例2: test_success_call_validator
def test_success_call_validator(self, validator_mock):
with self.patch_requests() as ur:
ct = self.content_type + "; charset=utf-8"
ur.headers = {"content-type": ct}
tasks.fetch_manifest("http://xx.com/manifest.json", self.upload.pk)
assert validator_mock.called
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例3: test_connection_error
def test_connection_error(self):
reason = socket.gaierror(8, 'nodename nor servname provided')
self.urlopen_mock.side_effect = urllib2.URLError(reason)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:rtnpro,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例4: test_detail_for_free_extension_webapp
def test_detail_for_free_extension_webapp(self, validator_mock,
requests_mock):
content = self.file_content('mozball.owa')
response_mock = mock.Mock(status_code=200)
response_mock.iter_content.return_value = mock.Mock(
next=lambda: content)
response_mock.headers = {'content-type': self.content_type}
yield response_mock
requests_mock.return_value = response_mock
validator_mock.return_value = json.dumps(self.validation_ok())
self.upload_file('mozball.owa')
upload = FileUpload.objects.get()
tasks.fetch_manifest('http://xx.com/manifest.owa', upload.pk)
r = self.client.get(reverse('mkt.developers.upload_detail',
args=[upload.uuid, 'json']))
data = json.loads(r.content)
eq_(data['validation']['messages'], []) # no errors
assert_no_validation_errors(data) # no exception
eq_(r.status_code, 200)
eq_(data['url'],
reverse('mkt.developers.upload_detail', args=[upload.uuid,
'json']))
eq_(data['full_report_url'],
reverse('mkt.developers.upload_detail', args=[upload.uuid]))
开发者ID:prabinb,项目名称:zamboni,代码行数:26,代码来源:test_views.py
示例5: create
def create(self, request, *args, **kwargs):
"""
Custom create method allowing us to re-use form logic and distinguish
packaged app from hosted apps, applying delays to the validation task
if necessary.
Doesn't rely on any serializer, just forms.
"""
data = self.request.data
packaged = 'upload' in data
form = (NewPackagedForm(data) if packaged
else NewManifestForm(data))
if not form.is_valid():
return Response(form.errors, status=HTTP_400_BAD_REQUEST)
if not packaged:
upload = FileUpload.objects.create(
user=request.user if request.user.is_authenticated() else None)
# The hosted app validator is pretty fast.
tasks.fetch_manifest(form.cleaned_data['manifest'], upload.pk)
else:
upload = form.file_upload
# The packaged app validator is much heavier.
tasks.validator.delay(upload.pk)
log.info('Validation created: %s' % upload.pk)
self.kwargs = {'pk': upload.pk}
# Re-fetch the object, fetch_manifest() might have altered it.
upload = self.get_object()
serializer = self.get_serializer(upload)
status = HTTP_201_CREATED if upload.processed else HTTP_202_ACCEPTED
return Response(serializer.data, status=status)
开发者ID:digideskio,项目名称:zamboni,代码行数:33,代码来源:views.py
示例6: test_http_error
def test_http_error(self):
self.urlopen_mock.side_effect = urllib2.HTTPError(
'url', 404, 'Not Found', [], None)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:rtnpro,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例7: test_url_timeout
def test_url_timeout(self):
reason = socket.timeout('too slow')
self.urlopen_mock.side_effect = urllib2.URLError(reason)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:rtnpro,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例8: test_success_call_validator
def test_success_call_validator(self, validator_mock):
with self.patch_urlopen() as ur:
ct = self.content_type + '; charset=utf-8'
ur.headers = {'Content-Type': ct}
tasks.fetch_manifest('http://xx.com/manifest.json', self.upload.pk)
assert validator_mock.called
开发者ID:rtnpro,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例9: test_response_too_large
def test_response_too_large(self):
with self.patch_urlopen() as ur:
content = 'x' * (settings.MAX_WEBAPP_UPLOAD_SIZE + 1)
ur.read.return_value = content
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation('Your manifest must be less than 2097152 bytes.')
开发者ID:ominds,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例10: test_success_add_file
def test_success_add_file(self, validator_mock):
with self.patch_requests() as ur:
ur.iter_content.return_value = mock.Mock(next=lambda: 'woo')
tasks.fetch_manifest('http://xx.com/manifest.json', self.upload.pk)
upload = FileUpload.objects.get(pk=self.upload.pk)
eq_(upload.name, 'http://xx.com/manifest.json')
eq_(storage.open(upload.path).read(), 'woo')
开发者ID:j-barron,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例11: test_http_error
def test_http_error(self):
self.urlopen_mock.side_effect = urllib2.HTTPError(
'url', 404, 'Not Found', [], None)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and make'
' sure the manifest is served with the HTTP header '
'"Content-Type: application/x-web-app-manifest+json".')
开发者ID:ominds,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例12: test_response_too_large
def test_response_too_large(self):
with self.patch_requests() as ur:
content = "x" * (settings.MAX_WEBAPP_UPLOAD_SIZE + 1)
ur.iter_content.return_value = mock.Mock(next=lambda: content)
tasks.fetch_manifest("url", self.upload.pk)
max_webapp_size = settings.MAX_WEBAPP_UPLOAD_SIZE
self.check_validation("Your manifest must be less than %s bytes." % max_webapp_size)
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例13: test_http_error
def test_http_error(self):
with self.patch_requests() as ur:
ur.status_code = 404
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:j-barron,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例14: test_other_url_error
def test_other_url_error(self):
reason = Exception('Some other failure.')
self.urlopen_mock.side_effect = urllib2.URLError(reason)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and make'
' sure the manifest is served with the HTTP header '
'"Content-Type: application/x-web-app-manifest+json".')
开发者ID:ominds,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例15: test_connection_error
def test_connection_error(self):
reason = socket.gaierror(8, 'nodename nor servname provided')
self.urlopen_mock.side_effect = urllib2.URLError(reason)
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and make'
' sure the manifest is served with the HTTP header '
'"Content-Type: application/x-web-app-manifest+json".')
开发者ID:ominds,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例16: test_bad_content_type
def test_bad_content_type(self):
with self.patch_urlopen() as ur:
ur.headers = {'Content-Type': 'x'}
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'Your manifest must be served with the HTTP header '
'"Content-Type: application/x-web-app-manifest+json". We saw "x".')
开发者ID:albre2252,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例17: test_non_utf8_encoding
def test_non_utf8_encoding(self):
with self.patch_requests() as ur:
with open(self.file("utf8bom.webapp")) as fp:
# Set encoding to utf16 which will be invalid.
content = fp.read().decode("utf8").encode("utf16")
ur.iter_content.return_value = mock.Mock(next=lambda: content)
tasks.fetch_manifest("url", self.upload.pk)
self.check_validation("Your manifest file was not encoded as valid UTF-8.")
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例18: test_no_content_type
def test_no_content_type(self):
with self.patch_requests() as ur:
ur.headers = {}
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'No manifest was found at that URL. Check the address and try '
'again.')
开发者ID:j-barron,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例19: test_bad_charset
def test_bad_charset(self):
with self.patch_requests() as ur:
ur.headers = {"content-type": "application/x-web-app-manifest+json;" "charset=ISO-1234567890-LOL"}
tasks.fetch_manifest("url", self.upload.pk)
self.check_validation(
"The manifest's encoding does not match the " "charset provided in the HTTP Content-Type."
)
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
示例20: test_non_utf8_encoding
def test_non_utf8_encoding(self):
with self.patch_urlopen() as ur:
with open(self.file('utf8bom.webapp')) as fp:
# Set encoding to utf16 which will be invalid
ur.read.return_value = fp.read().decode('utf8').encode('utf16')
tasks.fetch_manifest('url', self.upload.pk)
self.check_validation(
'Your manifest file was not encoded as valid UTF-8.')
开发者ID:rtnpro,项目名称:zamboni,代码行数:8,代码来源:test_tasks.py
注:本文中的mkt.developers.tasks.fetch_manifest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论