当前位置: 首页>>代码示例>>Python>>正文


Python Extension.from_upload方法代码示例

本文整理汇总了Python中mkt.extensions.models.Extension.from_upload方法的典型用法代码示例。如果您正苦于以下问题:Python Extension.from_upload方法的具体用法?Python Extension.from_upload怎么用?Python Extension.from_upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.extensions.models.Extension的用法示例。


在下文中一共展示了Extension.from_upload方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_upload_new

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
 def test_upload_new(self):
     eq_(Extension.objects.count(), 0)
     upload = self.upload('extension')
     extension = Extension.from_upload(upload, user=self.user)
     eq_(extension.version, '0.1')
     eq_(list(extension.authors.all()), [self.user])
     eq_(extension.name, u'My Lîttle Extension')
     eq_(extension.default_language, 'en-GB')
     eq_(extension.slug, u'my-lîttle-extension')
     eq_(extension.filename, 'extension-%s.zip' % extension.version)
     ok_(extension.filename in extension.file_path)
     ok_(private_storage.exists(extension.file_path))
     eq_(extension.manifest, self.expected_manifest)
     eq_(Extension.objects.count(), 1)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:16,代码来源:test_models.py

示例2: test_upload_new

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
 def test_upload_new(self):
     eq_(Extension.objects.count(), 0)
     upload = self.upload('extension')
     extension = Extension.from_upload(upload)
     eq_(extension.version, '0.1')
     eq_(extension.name, u'My Lîttle Extension')
     eq_(extension.default_language, 'en-GB')
     eq_(extension.slug, u'my-lîttle-extension')
     eq_(extension.filename, 'extension-%s.zip' % extension.version)
     ok_(extension.filename in extension.file_path)
     ok_(extension.file_path.startswith(extension.path_prefix))
     ok_(private_storage.exists(extension.file_path))
     eq_(extension.manifest, self.expected_manifest)
     eq_(Extension.objects.count(), 1)
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:16,代码来源:test_models.py

示例3: test_upload_new

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
    def test_upload_new(self):
        eq_(Extension.objects.count(), 0)
        upload = self.upload('extension')
        extension = Extension.from_upload(upload, user=self.user)
        ok_(extension.pk)
        eq_(extension.latest_version, ExtensionVersion.objects.latest('pk'))
        eq_(Extension.objects.count(), 1)
        eq_(ExtensionVersion.objects.count(), 1)

        eq_(list(extension.authors.all()), [self.user])
        eq_(extension.name, u'My Lîttle Extension')
        eq_(extension.default_language, 'en-GB')
        eq_(extension.description, u'A Dummÿ Extension')
        eq_(extension.slug, u'my-lîttle-extension')
        eq_(extension.status, STATUS_PENDING)
        ok_(extension.uuid)

        version = extension.latest_version
        eq_(version.version, '0.1')
        eq_(version.default_language, 'en-GB')
        eq_(version.filename, 'extension-%s.zip' % version.version)
        ok_(version.filename in version.file_path)
        ok_(private_storage.exists(version.file_path))
        eq_(version.manifest, self.expected_manifest)
开发者ID:demagu-sr,项目名称:zamboni,代码行数:26,代码来源:test_models.py

示例4: create

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
    def create(self, request, *args, **kwargs):
        upload_pk = request.DATA.get('upload', '')
        if not upload_pk:
            raise exceptions.ParseError(_('No upload identifier specified.'))

        if not request.user.is_authenticated():
            raise exceptions.PermissionDenied(
                _('You need to be authenticated to perform this action.'))

        try:
            upload = FileUpload.objects.get(pk=upload_pk, user=request.user)
        except FileUpload.DoesNotExist:
            raise Http404(_('No such upload.'))
        if not upload.valid:
            raise exceptions.ParseError(
                _('The specified upload has not passed validation.'))

        try:
            obj = Extension.from_upload(upload, user=request.user)
        except ValidationError as e:
            raise exceptions.ParseError(unicode(e))
        log.info('Extension created: %s' % obj.pk)
        serializer = self.get_serializer(obj)
        return Response(serializer.data, status=status.HTTP_201_CREATED)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:26,代码来源:views.py

示例5: test_upload_existing

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
 def test_upload_existing(self):
     extension = self.create_extension()
     upload = self.upload('extension')
     with self.assertRaises(NotImplementedError):
         Extension.from_upload(upload, instance=extension)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例6: test_upload_no_name

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
 def test_upload_no_name(self, manifest_mock):
     manifest_mock.__get__ = mock.Mock(return_value={'version': '0.1'})
     upload = self.upload('extension')
     with self.assertRaises(ValidationError):
         Extension.from_upload(upload)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例7: test_upload_no_name

# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import from_upload [as 别名]
 def test_upload_no_name(self, validate_mock):
     validate_mock.return_value = {'version': '0.1'}
     upload = self.upload('extension')
     with self.assertRaises(ParseError):
         Extension.from_upload(upload, user=self.user)
开发者ID:,项目名称:,代码行数:7,代码来源:


注:本文中的mkt.extensions.models.Extension.from_upload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。